Skip to content

Commit 51fcc1f

Browse files
committed
Add all trait ancestors to the list of parents in bytecode
... to allow us to call arbitrary super methods with invokespecial
1 parent b2246b9 commit 51fcc1f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/scala/tools/nsc/backend/jvm/BTypesFromSymbols.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ class BTypesFromSymbols[G <: Global](val global: G) extends BTypes {
251251
// class C extends Object with A // minimizeParents removes Object
252252
ifs
253253
}
254-
interfaces.map(_.typeSymbol)
254+
// Add all mixin traits as direct parents of classes so we can emit arbitrary super calls to default methods with invokespecial
255+
// TODO also reflect this in the generic signatures (?)
256+
val mixinTraitsOfClass = if (!classSym.isJavaDefined && !classSym.isTrait) classSym.ancestors.filter(_.isTrait) else Nil
257+
(interfaces.map(_.typeSymbol) ::: mixinTraitsOfClass).distinct
258+
255259
}
256260

257261
/**

0 commit comments

Comments
 (0)