Skip to content

Commit 7a99c03

Browse files
committed
Don't generate redundant interfaces.
Dropped redundant parents during bytecode generation to ease trouble on android. Closes SI-5278.
1 parent 3b65ef1 commit 7a99c03

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,18 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
308308

309309
private var innerClassBuffer = mutable.LinkedHashSet[Symbol]()
310310

311+
/** Drop redundant interfaces (ones which are implemented by some
312+
* other parent) from the immediate parents. This is important on
313+
* android because there is otherwise an interface explosion.
314+
*/
315+
private def minimizeInterfaces(interfaces: List[Symbol]): List[Symbol] = (
316+
interfaces filterNot (int1 =>
317+
interfaces exists (int2 =>
318+
(int1 ne int2) && (int2 isSubClass int1)
319+
)
320+
)
321+
)
322+
311323
def genClass(c: IClass) {
312324
clasz = c
313325
innerClassBuffer.clear()
@@ -322,7 +334,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
322334
}
323335
val ifaces = superInterfaces match {
324336
case Nil => JClass.NO_INTERFACES
325-
case _ => mkArray(superInterfaces map (x => javaName(x.typeSymbol)))
337+
case _ => mkArray(minimizeInterfaces(superInterfaces map (_.typeSymbol)) map javaName)
326338
}
327339

328340
jclass = fjbgContext.JClass(javaFlags(c.symbol),

0 commit comments

Comments
 (0)