Skip to content

Commit ccb8363

Browse files
committed
non-unit-typed lazy vals in traits still get field -- see neg/t5455.scala
1 parent 273cb20 commit ccb8363

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

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

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

0 commit comments

Comments
 (0)