@@ -215,10 +215,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
215
215
}
216
216
217
217
// Additional interface parents based on annotations and other cues
218
- def newParentForAttr (attr : Symbol ): Option [Type ] = attr match {
219
- case SerializableAttr => Some (SerializableClass .tpe )
220
- case CloneableAttr => Some (JavaCloneableClass .tpe )
221
- case RemoteAttr => Some (RemoteInterfaceClass .tpe )
218
+ def newParentForAttr (attr : Symbol ): Option [Symbol ] = attr match {
219
+ case SerializableAttr => Some (SerializableClass )
220
+ case CloneableAttr => Some (JavaCloneableClass )
221
+ case RemoteAttr => Some (RemoteInterfaceClass )
222
222
case _ => None
223
223
}
224
224
@@ -378,38 +378,44 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
378
378
379
379
private var innerClassBuffer = mutable.LinkedHashSet [Symbol ]()
380
380
381
- /** Drop redundant interfaces (ones which are implemented by some
382
- * other parent) from the immediate parents. This is important on
383
- * android because there is otherwise an interface explosion.
381
+ /** Drop redundant interfaces (ones which are implemented by some other parent) from the immediate parents.
382
+ * This is important on Android because there is otherwise an interface explosion.
384
383
*/
385
- private def minimizeInterfaces (interfaces : List [Symbol ]): List [Symbol ] = (
386
- interfaces filterNot (int1 =>
387
- interfaces exists (int2 =>
388
- (int1 ne int2) && (int2 isSubClass int1)
389
- )
390
- )
391
- )
384
+ private def minimizeInterfaces (interfaces : List [Symbol ]): List [Symbol ] = {
385
+ var rest = interfaces
386
+ var leaves = List .empty[Symbol ]
387
+ while (! rest.isEmpty) {
388
+ val candidate = rest.head
389
+ val nonLeaf = leaves exists { lsym => lsym isSubClass candidate }
390
+ if (! nonLeaf) {
391
+ leaves = candidate :: (leaves filterNot { lsym => candidate isSubClass lsym })
392
+ }
393
+ rest = rest.tail
394
+ }
395
+
396
+ leaves
397
+ }
392
398
393
399
def genClass (c : IClass ) {
394
400
clasz = c
395
401
innerClassBuffer.clear()
396
402
397
403
val name = javaName(c.symbol)
398
- val superClass :: superInterfaces = {
399
- val parents0 = c.symbol.info.parents match {
400
- case Nil => List ( ObjectClass .tpe)
401
- case ps => ps
402
- }
403
- parents0 ++ c.symbol.annotations.flatMap(ann => newParentForAttr(ann.symbol)) distinct
404
- }
405
- val ifaces = superInterfaces match {
406
- case Nil => JClass . NO_INTERFACES
407
- case _ => mkArray(minimizeInterfaces( superInterfaces map (_.typeSymbol)) map javaName)
408
- }
404
+
405
+ val ps = c.symbol.info.parents
406
+
407
+ val superClass : Symbol = if (ps.isEmpty) ObjectClass else ps.head.typeSymbol;
408
+
409
+ val superInterfaces0 : List [ Symbol ] = if (ps.isEmpty) Nil else c.symbol.mixinClasses;
410
+ val superInterfaces = superInterfaces0 ++ c.symbol.annotations.flatMap(ann => newParentForAttr(ann.symbol)) distinct
411
+
412
+ val ifaces =
413
+ if ( superInterfaces.isEmpty) JClass . NO_INTERFACES
414
+ else mkArray(minimizeInterfaces(superInterfaces) map javaName)
409
415
410
416
jclass = fjbgContext.JClass (javaFlags(c.symbol),
411
417
name,
412
- javaName(superClass.typeSymbol ),
418
+ javaName(superClass),
413
419
ifaces,
414
420
c.cunit.source.toString)
415
421
0 commit comments