diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-05-29 21:45:08 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-11 10:59:16 -0700 |
commit | 8f792280630721bdc1e6ee9199eb0cf8cb035fce (patch) | |
tree | 3034a2e1d7cb19e33a1ee62cbff299a53e39b1ce /src/reflect | |
parent | 6f0bb49c17ea1a46283777e39ed5ce016aa048a5 (diff) | |
download | scala-8f792280630721bdc1e6ee9199eb0cf8cb035fce.tar.gz scala-8f792280630721bdc1e6ee9199eb0cf8cb035fce.tar.bz2 scala-8f792280630721bdc1e6ee9199eb0cf8cb035fce.zip |
Simplify erasure + mixin
Remove some old, obsolete & untested hacks from ExplicitOuter.
Added a test for one of them to show this is now fine.
There are a lot of `makeNotPrivate` invocations sprinkled around
the codebase. Lets see if we can centralize the ones dealing
with trait methods that need implementations in the phase that emits them.
For example Fields (accessors for fields/modules) or SuperAccessors.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/transform/Erasure.scala | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 35ec80901e..eca1bbea5a 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -1040,11 +1040,7 @@ trait Definitions extends api.StandardDefinitions { } } - /** Remove references to class Object (other than the head) in a list of parents */ - def removeLaterObjects(tps: List[Type]): List[Type] = tps match { - case Nil => Nil - case x :: xs => x :: xs.filterNot(_.typeSymbol == ObjectClass) - } + /** Remove all but one reference to class Object from a list of parents. */ def removeRedundantObjects(tps: List[Type]): List[Type] = tps match { case Nil => Nil diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 412c49f571..62ca50d035 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -148,9 +148,19 @@ trait Erasure { apply(atp) case ClassInfoType(parents, decls, clazz) => ClassInfoType( - if (clazz == ObjectClass || isPrimitiveValueClass(clazz)) Nil + if (clazz == ObjectClass || isPrimitiveValueClass(clazz) || parents.isEmpty) Nil else if (clazz == ArrayClass) ObjectTpe :: Nil - else removeLaterObjects(parents map this), + else { + val erasedParents = parents map this + + // drop first parent for traits -- it has been normalized to a class by now, + // but we should drop that in bytecode + val firstParent = + if (clazz.hasFlag(Flags.TRAIT) && !clazz.hasFlag(Flags.JAVA)) ObjectTpe + else erasedParents.head + + firstParent :: erasedParents.tail.filter(_.typeSymbol != ObjectClass) + }, decls, clazz) case _ => mapOver(tp) |