diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-12-05 15:26:43 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-12-16 13:15:03 +0100 |
commit | 68e2a8ccb82158e6af6b74857f9681ff46990c59 (patch) | |
tree | 025dee8c0ffcd0827d59eb18858e68b42056a0ac /src | |
parent | 7b2c5ba0b8ba36b443c7d2ca474142e03cb8b16e (diff) | |
download | dotty-68e2a8ccb82158e6af6b74857f9681ff46990c59.tar.gz dotty-68e2a8ccb82158e6af6b74857f9681ff46990c59.tar.bz2 dotty-68e2a8ccb82158e6af6b74857f9681ff46990c59.zip |
Untroduce SumUtils.superInterfaces which is different from mixins.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/SymUtils.scala | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/transform/SymUtils.scala b/src/dotty/tools/dotc/transform/SymUtils.scala index 08a0585dc..9274150b1 100644 --- a/src/dotty/tools/dotc/transform/SymUtils.scala +++ b/src/dotty/tools/dotc/transform/SymUtils.scala @@ -30,15 +30,24 @@ class SymUtils(val self: Symbol) extends AnyVal { 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 + 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. */ def mixins(implicit ctx: Context) = { - val superCls = self.superClass if (self is Trait) Nil - else { - val baseClasses = self.asClass.baseClasses - if (baseClasses.isEmpty) Nil - else baseClasses.tail.takeWhile(_ ne superCls).reverse - } + else superInterfaces } def isTypeTestOrCast(implicit ctx: Context): Boolean = |