File tree 1 file changed +6
-0
lines changed
src/compiler/scala/tools/nsc/typechecker
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1340,7 +1340,13 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
1340
1340
notAllowed(s " redefinition of $name method. See SIP-15, criterion 4. " )
1341
1341
else if (stat.symbol != null && stat.symbol.isParamAccessor)
1342
1342
notAllowed(" additional parameter" )
1343
+ // concrete accessor (getter) in trait corresponds to a field definition (neg/anytrait.scala)
1344
+ // TODO: only reject accessors that actually give rise to field (e.g., a constant-type val is fine)
1345
+ else if (! isValueClass && stat.symbol.isAccessor && ! stat.symbol.isDeferred)
1346
+ notAllowed(" field definition" )
1343
1347
checkEphemeralDeep.traverse(rhs)
1348
+ // for value class or "exotic" vals in traits
1349
+ // (traits don't receive ValDefs for regular vals until fields phase -- well, except for early initialized/lazy vals)
1344
1350
case _ : ValDef =>
1345
1351
notAllowed(" field definition" )
1346
1352
case _ : ModuleDef =>
You can’t perform that action at this time.
0 commit comments