diff options
Diffstat (limited to 'src/dotty/tools/dotc/TypeErasure.scala')
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 7920667e7..3f9149214 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -317,9 +317,19 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild if (cls is Package) tp else { def eraseTypeRef(p: TypeRef) = this(p).asInstanceOf[TypeRef] - val parents: List[TypeRef] = + val parents: List[TypeRef] = { if ((cls eq defn.ObjectClass) || cls.isPrimitiveValueClass) Nil - else removeLaterObjects(classParents.mapConserve(eraseTypeRef)) + else { + def normalize(trs: List[TypeRef])(implicit ctx: Context): List[TypeRef] = trs match { + case tr :: trs1 => + assert(!tr.classSymbol.is(Trait), cls) + val tr1 = if (cls is Trait) defn.ObjectClass.typeRef else tr + tr1 :: trs1.filterNot(_ isRef defn.ObjectClass) + case nil => nil + } + normalize(classParents.mapConserve(eraseTypeRef)) + } + } val erasedDecls = decls.filteredScope(d => !d.isType || d.isClass) tp.derivedClassInfo(NoPrefix, parents, erasedDecls, erasedRef(tp.selfType)) // can't replace selftype by NoType because this would lose the sourceModule link @@ -376,11 +386,6 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild cls } - private def removeLaterObjects(trs: List[TypeRef])(implicit ctx: Context): List[TypeRef] = trs match { - case tr :: trs1 => tr :: trs1.filterNot(_ isRef defn.ObjectClass) - case nil => nil - } - /** The name of the type as it is used in `Signature`s. * Need to ensure correspondence with erasure! */ |