aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/TypeErasure.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-12-05 14:24:06 +0100
committerMartin Odersky <odersky@gmail.com>2014-12-05 14:36:56 +0100
commit45fd08763fa9f1a45114ce8cd6125e6a83bf3409 (patch)
treedfa5cf37aac42abaffcf7299bfb9da847f9d02cf /src/dotty/tools/dotc/TypeErasure.scala
parent86eb1bb2b5f9ddd9ed8ff45fc304e29c5f6c668d (diff)
downloaddotty-45fd08763fa9f1a45114ce8cd6125e6a83bf3409.tar.gz
dotty-45fd08763fa9f1a45114ce8cd6125e6a83bf3409.tar.bz2
dotty-45fd08763fa9f1a45114ce8cd6125e6a83bf3409.zip
Fix erasure of trait info
After erasure, traits always extend object, and no other class. The change flushed out three more problems, one in the handling of Super trees in erasure, another in bridge method generation. and a third that class RepeatedParam had Seq, which is a trait, as first parent.
Diffstat (limited to 'src/dotty/tools/dotc/TypeErasure.scala')
-rw-r--r--src/dotty/tools/dotc/TypeErasure.scala19
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!
*/