Skip to content

Commit 9be27ae

Browse files
committed
Refactoring and renaming of superClass/superInterfaces
superClass was a duplicate; we already have one in SymDenotation, so we delete the one in SymUtils. superInterfaces is too easy to confused with the JVM notion, which is different. I replaced with directlyInheritedTraits.
1 parent 7c121a8 commit 9be27ae

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/dotty/tools/backend/jvm/DottyBackendInterface.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
647647
}
648648
def parentSymbols: List[Symbol] = toDenot(sym).info.parents.map(_.typeSymbol)
649649
def superClass: Symbol = {
650-
val t = toDenot(sym).superClass
650+
val t = toDenot(sym).asClass.superClass
651651
if (t.exists) t
652652
else if (sym is Flags.ModuleClass) {
653653
// workaround #371
@@ -712,7 +712,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
712712
* All interfaces implemented by a class, except for those inherited through the superclass.
713713
*
714714
*/
715-
def superInterfaces: List[Symbol] = decorateSymbol(sym).superInterfaces
715+
def superInterfaces: List[Symbol] = decorateSymbol(sym).directlyInheritedTraits
716716

717717
/**
718718
* True for module classes of package level objects. The backend will generate a mirror class for

src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,20 @@ object SymUtils {
2424
class SymUtils(val self: Symbol) extends AnyVal {
2525
import SymUtils._
2626

27-
def superClass(implicit ctx: Context) = {
28-
val parents = self.asClass.classInfo.parents
29-
if (parents.isEmpty) NoSymbol
30-
else parents.head.symbol
31-
}
32-
33-
34-
/**
35-
* For a class: All interfaces implemented by a class except for those inherited through the superclass.
36-
* For a trait: all parent traits
37-
*/
38-
39-
def superInterfaces(implicit ctx: Context) = {
40-
val superCls = self.superClass
27+
/** All traits implemented by a class or trait except for those inherited through the superclass. */
28+
def directlyInheritedTraits(implicit ctx: Context) = {
29+
val superCls = self.asClass.superClass
4130
val baseClasses = self.asClass.baseClasses
4231
if (baseClasses.isEmpty) Nil
4332
else baseClasses.tail.takeWhile(_ ne superCls).reverse
44-
4533
}
4634

47-
/** All interfaces implemented by a class, except for those inherited through the superclass. */
35+
/** All traits implemented by a class, except for those inherited through the superclass.
36+
* The empty list if `self` is a trait.
37+
*/
4838
def mixins(implicit ctx: Context) = {
4939
if (self is Trait) Nil
50-
else superInterfaces
40+
else directlyInheritedTraits
5141
}
5242

5343
def isTypeTestOrCast(implicit ctx: Context): Boolean =

0 commit comments

Comments
 (0)