Skip to content

Commit ed126d9

Browse files
Fix record's constructor
Co-authored-by: Guillaume Martres <smarter@users.noreply.github.com>
1 parent 68e720c commit ed126d9

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
@@ -854,7 +854,8 @@ object JavaParsers {
854854
).toList
855855

856856
// generate the canonical constructor
857-
val canonicalConstructor = makeConstructor(header, tparams)
857+
val canonicalConstructor =
858+
DefDef(nme.CONSTRUCTOR, joinParams(tparams, List(header)), TypeTree(), EmptyTree).withMods(Modifiers(Flags.JavaDefined, mods.privateWithin))
858859

859860
// return the trees
860861
val recordTypeDef = atSpan(start, nameOffset) {
@@ -863,7 +864,7 @@ object JavaParsers {
863864
parents = superclass :: interfaces,
864865
stats = canonicalConstructor :: accessors ::: body,
865866
tparams = tparams,
866-
false
867+
true
867868
)
868869
)
869870
}

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

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

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

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

0 commit comments

Comments
 (0)