Skip to content

Commit b9982d8

Browse files
committed
Fix flags for default getters of constructors
This manifested itself as a pickling difference in tasty_tools
1 parent 196b271 commit b9982d8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ object desugar {
179179
DefDef(
180180
name = meth.name.defaultGetterName(n),
181181
tparams = meth.tparams.map(tparam => dropContextBound(toDefParam(tparam))),
182-
vparamss = takeUpTo(normalizedVparamss, n),
182+
vparamss = takeUpTo(normalizedVparamss.nestedMap(toDefParam), n),
183183
tpt = TypeTree(),
184184
rhs = vparam.rhs
185185
).withMods(Modifiers(mods.flags & AccessFlags, mods.privateWithin))

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ class TreeChecker extends Phase with SymTransformer {
397397
withDefinedSyms(ddef.tparams) {
398398
withDefinedSymss(ddef.vparamss) {
399399
if (!sym.isClassConstructor && !(sym.name eq Names.STATIC_CONSTRUCTOR)) assert(isValidJVMMethodName(sym.name), s"${sym.fullName} name is invalid on jvm")
400+
401+
ddef.vparamss.foreach(_.foreach { vparam =>
402+
assert(vparam.symbol.is(Param),
403+
s"Parameter ${vparam.symbol} of ${sym.fullName} does not have flag `Param` set")
404+
assert(!vparam.symbol.is(AccessFlags),
405+
s"Parameter ${vparam.symbol} of ${sym.fullName} has invalid flag(s): ${vparam.symbol.flags & AccessFlags}")
406+
})
407+
400408
val tpdTree = super.typedDefDef(ddef, sym)
401409
assert(isMethodType(sym.info), i"wrong type, expect a method type for ${sym.fullName}, but found: ${sym.info}")
402410
tpdTree

0 commit comments

Comments
 (0)