You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
incoherent cyclic references between synthesized members
must replace old trait accessor symbols by mixed in symbols
in the infos of the mixed in symbols
```
trait T { val a: String ; val b: a.type }
class C extends T {
// a, b synthesized, but the a in b's type, a.type, refers to the original symbol, not the clone in C
}
```
symbols occurring in types of synthesized members
do not get rebound to other synthesized symbols
package <empty>#4 {
abstract <defaultparam/trait> trait N#7352 extends scala#22.AnyRef#2378 {
<method> <deferred> <mutable> <accessor> <triedcooking> <sub_synth> def N$_setter_$self_$eq#15011(x$1#15012: <empty>#3.this.N#7352): scala#23.this.Unit#2340;
<method> <deferred> <mutable> <accessor> <triedcooking> <sub_synth> def N$_setter_$n_$eq#15013(x$1#15014: N#7352.this.self#7442.type): scala#23.this.Unit#2340;
<method> def /*N*/$init$scala#7441(): scala#23.this.Unit#2340 = {
()
};
<method> <deferred> <stable> <accessor> <triedcooking> <sub_synth> def self#7442: <empty>#3.this.N#7352;
N#7352.this.N$_setter_$self_$eq#15011(scala#22.Predef#1729.$qmark$qmark$qmark#6917);
<method> <deferred> <stable> <accessor> <sub_synth> def n#7443: N#7352.this.self#7442.type;
N#7352.this.N$_setter_$n_$eq#15013(N#7352.this.self#7442)
};
abstract class M#7353 extends scala#22.AnyRef#2378 {
<method> <triedcooking> def <init>#13465(): <empty>#3.this.M#7353 = {
M#7353.super.<init>scala#2719();
()
};
<method> <deferred> <stable> <accessor> <triedcooking> def self#13466: <empty>#3.this.N#7352;
<method> <deferred> <stable> <accessor> def n#13467: M#7353.this.self#13466.type
};
class C#7354 extends M#7353 with <empty>#3.this.N#7352 {
<method> <stable> <accessor> <triedcooking> def self#15016: <empty>#3.this.N#7352 = C#7354.this.self #15015;
<triedcooking> private[this] val self #15015: <empty>#3.this.N#7352 = _;
<method> <stable> <accessor> def n#15018: C#7354.this.self#7442.type = C#7354.this.n #15017;
<triedcooking> private[this] val n #15017: C#7354.this.self#7442.type = _;
<method> <mutable> <accessor> <triedcooking> def N$_setter_$self_$eq#15019(x$1#15021: <empty>#3.this.N#7352): scala#23.this.Unit#2340 = C#7354.this.self #15015 = x$1#15021;
<method> <mutable> <accessor> <triedcooking> def N$_setter_$n_$eq#15022(x$1#15025: C#7354.this.self#7442.type): scala#23.this.Unit#2340 = C#7354.this.n #15017 = x$1#15025;
<method> def <init>#14997(): <empty>#3.this.C#7354 = {
C#7354.super.<init>#13465();
()
}
}
}
[running phase pickler on dependent_rebind.scala]
[running phase refchecks on dependent_rebind.scala]
test/files/trait-defaults/dependent_rebind.scala:16: error: overriding field n#15049 in trait N#7352 of type C#7354.this.self#15016.type;
value n #15017 has incompatible type;
found : => C#7354.this.self#7442.type (with underlying type => C#7354.this.self#7442.type)
required: => N#7352.this.self#7442.type
class C extends M with N
^
@@ -264,19 +266,28 @@ abstract class Fields extends InfoTransform with ast.TreeDSL with TypingTransfor
264
266
} elseList(cloneAccessor())
265
267
}
266
268
267
-
// println(s"new decls for $clazz: $mixedInFieldAndAccessors")
269
+
// println(s"new decls for $clazz: $mixedInAccessorAndFields")
268
270
269
271
// omit fields that are not memoized, retain all other members
270
272
defomittableField(sym: Symbol) = sym.isValue &&!sym.isMethod && fieldMemoizationIn(sym, clazz).effectOnly // TODO: not yet `needsField`, to produce same bytecode as M2
271
273
272
274
valnewDecls=
273
-
if (mixedInFieldAndAccessors.isEmpty) oldDecls.filterNot(omittableField)
275
+
if (mixedInAccessorAndFields.isEmpty) oldDecls.filterNot(omittableField)
274
276
else { // must not alter `decls` directly
275
277
valnewDecls= newScope
276
278
oldDecls foreach { d =>if (!omittableField(d)) newDecls.enter(d) }
277
-
mixedInFieldAndAccessors foreach newDecls.enter
279
+
valenter= { mixedin: Symbol=> newDecls enter mixedin }
280
+
mixedInAccessorAndFields foreach { _ foreach enter }
281
+
282
+
// subst from accessors to corresponding clonedAccessors in types in newDecls
283
+
val (origs, mixedins) = (accessorsMaybeNeedingImpl, mixedInAccessorAndFields).zipped.collect {
284
+
case (traitAccessor, mixedin :: _) => (traitAccessor, mixedin)
0 commit comments