File tree 4 files changed +74
-1
lines changed
compiler/src/dotty/tools/dotc
4 files changed +74
-1
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,10 @@ object TypeOps:
196
196
// Mapping over a skolem creates a new skolem which by definition won't
197
197
// be =:= to the original one.
198
198
tp
199
+ case tp : SuperType =>
200
+ // Mapping a supertype might re-balance an AndType which is not permitted since
201
+ // we need the original order of parents for current super resolution.
202
+ tp
199
203
case _ =>
200
204
mapOver
201
205
}
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ trait TypeAssigner {
255
255
else if (ctx.erasedTypes) cls.info.firstParent.typeConstructor
256
256
else {
257
257
val ps = cls.classInfo.parents
258
- if ( ps.isEmpty) defn.AnyType else ps.reduceLeft(( x : Type , y : Type ) => x & y )
258
+ if ps.isEmpty then defn.AnyType else ps.reduceLeft(AndType (_, _) )
259
259
}
260
260
SuperType (cls.thisType, owntype)
261
261
Original file line number Diff line number Diff line change
1
+ Test 1
2
+ D
3
+ B
4
+ C
5
+ A
6
+ Test 2
7
+ D
8
+ B
9
+ C
10
+ A
11
+ Test 3
12
+ D
13
+ B
14
+ C
15
+ A
Original file line number Diff line number Diff line change
1
+ trait A {
2
+ def print : Unit = println(" A" )
3
+ }
4
+
5
+ trait B extends A {
6
+ override def print : Unit = {
7
+ println(" B" )
8
+ super .print
9
+ }
10
+ }
11
+
12
+ trait C extends A {
13
+ override def print : Unit = {
14
+ println(" C" )
15
+ super .print
16
+ }
17
+ }
18
+
19
+ trait D extends B {
20
+ override def print : Unit = {
21
+ println(" D" )
22
+ super .print
23
+ }
24
+ }
25
+
26
+ trait BB extends B
27
+
28
+ trait X
29
+ trait Y
30
+ trait Z
31
+
32
+ class Test1 extends C with B with BB with D with X with Y with Z :
33
+ override def print : Unit = {
34
+ println(" Test 1" )
35
+ super .print
36
+ }
37
+
38
+ class Test2 extends C with B with BB with D with X with Y {
39
+ override def print : Unit = {
40
+ println(" Test 2" )
41
+ super .print
42
+ }
43
+ }
44
+
45
+ class Test3 extends X with Y with Z with C with B with BB with D {
46
+ override def print : Unit = {
47
+ println(" Test 3" )
48
+ super .print
49
+ }
50
+ }
51
+ @ main def Test =
52
+ new Test1 ().print
53
+ new Test2 ().print
54
+ new Test3 ().print
You can’t perform that action at this time.
0 commit comments