File tree 3 files changed +89
-3
lines changed
compiler/src/dotty/tools/dotc/transform/init
3 files changed +89
-3
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,8 @@ object Checking {
93
93
val cls = cdef.symbol.asClass
94
94
val tpl = cdef.rhs.asInstanceOf [Template ]
95
95
96
+ if state.parentsInited.contains(cls) then return
97
+
96
98
// mark current class as initialized, required for linearization
97
99
state.parentsInited += cls
98
100
@@ -101,7 +103,7 @@ object Checking {
101
103
case vdef : ValDef =>
102
104
val summary = Summarization .analyze(vdef.rhs)
103
105
theEnv.summaryOf(cls).cacheFor(vdef.symbol, summary)
104
- if (! vdef.symbol.is (Flags .Lazy )) {
106
+ if (! vdef.symbol.isOneOf (Flags .Lazy | Flags . Deferred )) {
105
107
checkEffects(summary.effs)
106
108
traceIndented(vdef.symbol.show + " initialized" , init)
107
109
state.fieldsInited += vdef.symbol
@@ -170,7 +172,7 @@ object Checking {
170
172
171
173
case ref =>
172
174
val cls = ref.tpe.classSymbol.asClass
173
- if (! state.parentsInited.contains(cls) && cls.primaryConstructor.exists)
175
+ if (cls.primaryConstructor.exists)
174
176
checkConstructor(cls.primaryConstructor, ref.tpe, ref)
175
177
}
176
178
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ object Summarization {
318
318
val ctor = cls.primaryConstructor
319
319
val prefixEff =
320
320
if tref.prefix == NoPrefix then Effects .empty
321
- else Summarization .analyze(tref.prefix, ref)(env.withOwner(ctor.owner)) .effs
321
+ else Summarization .analyze(tref.prefix, ref).effs
322
322
323
323
prefixEff + MethodCall (ThisRef ()(ref), ctor)(ref)
324
324
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ object A requires B {
3
+ B.X getX() {
4
+ return B.getX();
5
+ }
6
+ void setX(B.X x) {}
7
+ }
8
+ object B {
9
+ class X {}
10
+ X getX() {
11
+ return new X();
12
+ }
13
+ void setX(X x) {}
14
+ }
15
+ object C requires B {
16
+ object A;
17
+ void test() {
18
+ A.setX(B.getX());
19
+ }
20
+ }
21
+ */
22
+
23
+ trait _a extends AnyRef with _b {
24
+ val a : _a;
25
+ val A : A ;
26
+ type A <: a.AObject ;
27
+ trait AObject {
28
+ def getX (): B .X ;
29
+ def setX (x : B .X ): Unit ;
30
+ }
31
+ }
32
+ trait a123 extends AnyRef with _a with _b {
33
+ val a : this .type = this ;
34
+ val A : A = new A ();
35
+ class A () extends AObject {
36
+ def getX (): B .X = B .getX();
37
+ def setX (x : B .X ) = B .setX(x);
38
+ }
39
+ }
40
+
41
+ trait _b {
42
+ val b : _b;
43
+ val B : B ;
44
+ type B <: b.BObject ;
45
+ trait BObject {
46
+ type X ;
47
+ def getX (): X ;
48
+ def setX (x : X ): Unit ;
49
+ }
50
+ }
51
+ abstract class b () extends AnyRef with _b {
52
+ val b : this .type = this ;
53
+ val B : B = new B ();
54
+ class B () extends BObject {
55
+ class X () {}
56
+ def getX (): X = new X ();
57
+ def setX (x : X ) = ();
58
+ }
59
+ }
60
+
61
+ trait _m {
62
+ val m : _m;
63
+ val M : M ;
64
+ type M <: m.MObject ;
65
+ trait MObject {}
66
+ }
67
+ abstract class m () extends AnyRef with _m with _b {
68
+ val m : this .type = this ;
69
+ val M : M = new M ();
70
+ class M () extends MObject with a123 with Linker {
71
+ def test () = {
72
+ val x : B .X = B .getX();
73
+ A .setX(x);
74
+ }
75
+ }
76
+ trait Linker {
77
+ val b : m.this .b.type = m.this .b;
78
+ val B : m.this .B .type = m.this .B ;
79
+ type B = m.this .B ;
80
+ val m : m.this .m.type = m.this .m;
81
+ val M : m.this .M .type = m.this .M ;
82
+ type M = m.this .M ;
83
+ }
84
+ }
You can’t perform that action at this time.
0 commit comments