aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
diff options
context:
space:
mode:
authorNicolas Stucki <nicolas.stucki@gmail.com>2016-07-05 10:50:47 +0200
committerNicolas Stucki <nicolas.stucki@gmail.com>2016-07-13 10:30:12 +0200
commit468ff9c0fd341395d39eb57959755fb718990035 (patch)
tree4fcdbb476adc8772c70a80e370a0be3786287669 /src/dotty/tools/backend/jvm/DottyBackendInterface.scala
parentbef40b45f6c15bf55fa73ea7923cb4da74cf77d0 (diff)
downloaddotty-468ff9c0fd341395d39eb57959755fb718990035.tar.gz
dotty-468ff9c0fd341395d39eb57959755fb718990035.tar.bz2
dotty-468ff9c0fd341395d39eb57959755fb718990035.zip
Fix #1209: Skip redundant superclasses\supertraits.
Diffstat (limited to 'src/dotty/tools/backend/jvm/DottyBackendInterface.scala')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index 23073d317..f42a8eee2 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -34,8 +34,11 @@ import NameOps._
import StdNames.nme
import NameOps._
import dotty.tools.dotc.core
+import dotty.tools.dotc.core.Names.TypeName
-class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context) extends BackendInterface{
+import scala.annotation.tailrec
+
+class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Map[Symbol, Set[ClassSymbol]])(implicit ctx: Context) extends BackendInterface{
type Symbol = Symbols.Symbol
type Type = Types.Type
type Tree = tpd.Tree
@@ -738,9 +741,14 @@ class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context
/**
* All interfaces implemented by a class, except for those inherited through the superclass.
- *
+ * Redundant interfaces are removed unless there is a super call to them.
*/
- def superInterfaces: List[Symbol] = decorateSymbol(sym).directlyInheritedTraits
+ def superInterfaces: List[Symbol] = {
+ val directlyInheritedTraits = decorateSymbol(sym).directlyInheritedTraits
+ val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.symbol.asClass.baseClasses.drop(1)).toSet
+ val superCalls = superCallsMap.getOrElse(sym, Set.empty)
+ directlyInheritedTraits.filter(t => !allBaseClasses(t) || superCalls(t))
+ }
/**
* True for module classes of package level objects. The backend will generate a mirror class for