diff options
author | Martin Odersky <odersky@gmail.com> | 2015-04-30 15:07:08 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-05-02 19:07:38 +0200 |
commit | 9be27ae2750b2554cf8d0719a4737f6420042995 (patch) | |
tree | b2df662404f85b327337ad6dcf8fadeb946a2fd3 | |
parent | 7c121a808bdd1cb3112d1471bc5c017e1e1de465 (diff) | |
download | dotty-9be27ae2750b2554cf8d0719a4737f6420042995.tar.gz dotty-9be27ae2750b2554cf8d0719a4737f6420042995.tar.bz2 dotty-9be27ae2750b2554cf8d0719a4737f6420042995.zip |
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.
-rw-r--r-- | src/dotty/tools/backend/jvm/DottyBackendInterface.scala | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/SymUtils.scala | 24 |
2 files changed, 9 insertions, 19 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 2e904cc23..fee8b95a2 100644 --- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -647,7 +647,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{ } def parentSymbols: List[Symbol] = toDenot(sym).info.parents.map(_.typeSymbol) def superClass: Symbol = { - val t = toDenot(sym).superClass + val t = toDenot(sym).asClass.superClass if (t.exists) t else if (sym is Flags.ModuleClass) { // workaround #371 @@ -712,7 +712,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{ * All interfaces implemented by a class, except for those inherited through the superclass. * */ - def superInterfaces: List[Symbol] = decorateSymbol(sym).superInterfaces + def superInterfaces: List[Symbol] = decorateSymbol(sym).directlyInheritedTraits /** * True for module classes of package level objects. The backend will generate a mirror class for diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala index 41a0938b8..9b4b06601 100644 --- a/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/src/dotty/tools/dotc/transform/SymUtils.scala @@ -24,30 +24,20 @@ object SymUtils { class SymUtils(val self: Symbol) extends AnyVal { import SymUtils._ - def superClass(implicit ctx: Context) = { - val parents = self.asClass.classInfo.parents - if (parents.isEmpty) NoSymbol - else parents.head.symbol - } - - - /** - * For a class: All interfaces implemented by a class except for those inherited through the superclass. - * For a trait: all parent traits - */ - - def superInterfaces(implicit ctx: Context) = { - val superCls = self.superClass + /** All traits implemented by a class or trait except for those inherited through the superclass. */ + def directlyInheritedTraits(implicit ctx: Context) = { + val superCls = self.asClass.superClass val baseClasses = self.asClass.baseClasses if (baseClasses.isEmpty) Nil else baseClasses.tail.takeWhile(_ ne superCls).reverse - } - /** All interfaces implemented by a class, except for those inherited through the superclass. */ + /** All traits implemented by a class, except for those inherited through the superclass. + * The empty list if `self` is a trait. + */ def mixins(implicit ctx: Context) = { if (self is Trait) Nil - else superInterfaces + else directlyInheritedTraits } def isTypeTestOrCast(implicit ctx: Context): Boolean = |