Closed
Description
Sorry for slightly long minimization, didn't manage to make it any shorter.
Behavior changed in 3.3.3, used to work fine in 2.13.13 and 3.3.1 at least.
Test1
is the reproduction - D.print
and B.print
are not getting called
Test2
has no with Z
, which shouldn't matter, and yet it "fixes" the problem
Test3
extends the X
, Y
and Z
traits first instead of last like Test1
, which also causes all print
s to run
Compiler version
3.3.1, 3.4.1
Minimized code
scala-cli run test.sc -S 3.3.3
test.sc
:
trait A {
def print: Unit = println("A")
}
trait B extends A {
override def print: Unit = {
println("B")
super.print
}
}
trait C extends A {
override def print: Unit = {
println("C")
super.print
}
}
trait D extends B {
override def print: Unit = {
println("D")
super.print
}
}
trait BB extends B
trait X
trait Y
trait Z
class Test1 extends C with B with BB with D with X with Y with Z {
override def print: Unit = {
println("Test 1")
super.print
}
}
new Test1().print
class Test2 extends C with B with BB with D with X with Y {
override def print: Unit = {
println("Test 2")
super.print
}
}
new Test2().print
class Test3 extends X with Y with Z with C with B with BB with D {
override def print: Unit = {
println("Test 3")
super.print
}
}
new Test3().print
Output
In scala 3.3.3 and 3.4.1:
Test 1
C
A
Test 2
D
B
C
A
Test 3
D
B
C
A
In scala 2.13.13 and 3.3.1:
Test 1
D
B
C
A
Test 2
D
B
C
A
Test 3
D
B
C
A
Expectation
Which super method calls are executed is not affected by "extra" traits