Skip to content

Commit 337a9dd

Browse files
committed
unit-typed lazy vals should never receive a field
this need was unmasked by test/files/run/t7843-jsr223-service.scala, which no longer printed the output expected from the `0 to 10 foreach`
1 parent 8405e72 commit 337a9dd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,10 @@ trait MethodSynthesis {
488488
// as the symbol info is in the process of being created then.
489489
// TODO: harmonize tree & symbol creation
490490
// TODO: the `def field` call-site breaks when you add `|| vd.symbol.owner.isTrait` (detected in test suite)
491-
def noFieldFor(vd: ValDef) = vd.mods.isDeferred || (owner.isTrait && !traitFieldFor(vd))
492-
493-
// TODO: remove need for this as we moved over all kinds of field to the getter-based encoding
494-
private def traitFieldFor(vd: ValDef): Boolean =
495-
(vd.mods.isLazy && !isUnitType(vd.symbol.info)) || vd.mods.hasFlag(PRESUPER)
491+
def noFieldFor(vd: ValDef) = vd.mods.isDeferred || (vd.mods.isLazy && isUnitType(vd.symbol.info)) || (owner.isTrait && !traitFieldFor(vd))
496492

493+
// TODO: never emit any fields in traits -- only use getter for lazy/presuper ones as well
494+
private def traitFieldFor(vd: ValDef): Boolean = vd.mods.hasFlag(PRESUPER)
497495
}
498496

499497
case class Field(tree: ValDef) extends DerivedFromValDef {

0 commit comments

Comments
 (0)