Skip to content

Commit 5bdd4c9

Browse files
Fix record's constructor
Co-authored-by: Guillaume Martres <[email protected]>
1 parent cb56936 commit 5bdd4c9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/JavaParsers.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,8 @@ object JavaParsers {
851851
).toList
852852

853853
// generate the canonical constructor
854-
val canonicalConstructor = makeConstructor(header, tparams)
854+
val canonicalConstructor =
855+
DefDef(nme.CONSTRUCTOR, joinParams(tparams, List(header)), TypeTree(), EmptyTree).withMods(Modifiers(Flags.JavaDefined, mods.privateWithin))
855856

856857
// return the trees, probably with addCompanionObject (like classDecl)
857858
val recordTypeDef = atSpan(start, nameOffset) {
@@ -860,7 +861,7 @@ object JavaParsers {
860861
parents = superclass :: interfaces,
861862
stats = canonicalConstructor :: accessors ::: body,
862863
tparams = tparams,
863-
false
864+
true
864865
)
865866
)
866867
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
34863486
adapt(tree, pt, ctx.typerState.ownedVars)
34873487

34883488
private def adapt1(tree: Tree, pt: Type, locked: TypeVars)(using Context): Tree = {
3489-
assert(pt.exists && !pt.isInstanceOf[ExprType] || ctx.reporter.errorsReported)
3489+
assert(pt.exists && !pt.isInstanceOf[ExprType] || ctx.reporter.errorsReported, i"tree: $tree, pt: $pt")
34903490
def methodStr = err.refStr(methPart(tree).tpe)
34913491

34923492
def readapt(tree: Tree)(using Context) = adapt(tree, pt, locked)

0 commit comments

Comments
 (0)