Skip to content

Commit 273cb20

Browse files
committed
skip presuper vals in new encoding
1 parent 631b636 commit 273cb20

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/compiler/scala/tools/nsc/transform/Constructors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL {
591591
case ValDef(mods, name, _, _) if mods hasFlag PRESUPER =>
592592
// stat is the constructor-local definition of the field value
593593
val fields = presupers filter (_.getterName == name)
594-
assert(fields.length == 1)
594+
assert(fields.length == 1, s"expected exactly one field by name $name in $presupers of $clazz's early initializers")
595595
val to = fields.head.symbol
596596

597597
if (memoizeValue(to)) constrStatBuf += mkAssign(to, Ident(stat.symbol))

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,10 @@ 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) = vd.mods.isDeferred || (vd.mods.isLazy && isUnitType(vd.symbol.info)) || owner.isTrait
489+
def noFieldFor(vd: ValDef) = (
490+
vd.mods.isDeferred
491+
|| (vd.mods.isLazy && isUnitType(vd.symbol.info))
492+
|| (owner.isTrait && !vd.mods.hasFlag(PRESUPER)))
490493
}
491494

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

0 commit comments

Comments
 (0)