summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-12-21 12:53:20 +0000
committerMartin Odersky <odersky@gmail.com>2009-12-21 12:53:20 +0000
commit482cf0e2ef0f630a7827fdfacf684449bf04596b (patch)
tree87bf7a84e05328e6872d0a38f732995aa18aafd5 /src/compiler
parente7e0d49dea014dfa21061bc5b5520b88aea23794 (diff)
downloadscala-482cf0e2ef0f630a7827fdfacf684449bf04596b.tar.gz
scala-482cf0e2ef0f630a7827fdfacf684449bf04596b.tar.bz2
scala-482cf0e2ef0f630a7827fdfacf684449bf04596b.zip
small cleanups. no review necessary.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala30
2 files changed, 19 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 7350410eeb..c4772b6407 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -139,8 +139,6 @@ trait Types {
}
}
-
-
/** A map from lists to compound types that have the given list as parents.
* This is used to avoid duplication in the computation of base type sequences and baseClasses.
* It makes use of the fact that these two operations depend only on the parents,
@@ -1763,7 +1761,7 @@ A type's typeSymbol should never be inspected directly.
packagePrefix + str
else if (sym.isModuleClass)
objectPrefix + str
- else if (sym.isAnonymousClass && sym.isInitialized && !settings.debug.value)
+ else if (sym.isAnonymousClass && sym.isInitialized && !settings.debug.value && !phase.erasedTypes)
thisInfo.parents.mkString(" with ") + {
if (sym.isStructuralRefinement)
((decls.toList filter { entry =>
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 9db88af6c6..1fa81c8776 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -116,6 +116,22 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
* </ul>
*/
val erasure = new TypeMap {
+
+ // Compute the erasure of the intersection type with given `parents` according to new spec.
+ private def intersectionErasure(parents: List[Type]): Type =
+ if (parents.isEmpty) erasedTypeRef(ObjectClass)
+ else {
+ // implement new spec for erasure of refined types.
+ val psyms = parents map (_.typeSymbol)
+ def isUnshadowed(psym: Symbol) =
+ !(psyms exists (qsym => (psym ne qsym) && (qsym isNonBottomSubClass psym)))
+ val cs = parents.iterator.filter { p => // isUnshadowed is a bit expensive, so try classes first
+ val psym = p.typeSymbol
+ psym.isClass && !psym.isTrait && isUnshadowed(psym)
+ }
+ apply((if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next())
+ }
+
def apply(tp: Type): Type = {
tp match {
case ConstantType(_) =>
@@ -129,6 +145,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
else typeRef(apply(pre), sym, args map this)
else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass) erasedTypeRef(ObjectClass)
else if (sym == UnitClass) erasedTypeRef(BoxedUnitClass)
+ else if (sym.isRefinementClass) intersectionErasure(tp.parents)
else if (sym.isClass) typeRef(apply(rebindInnerClass(pre, sym)), sym, List()) // #2585
else apply(sym.info) // alias type or abstract type
case PolyType(tparams, restpe) =>
@@ -145,18 +162,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
else
apply(restpe))
case RefinedType(parents, decls) =>
- if (parents.isEmpty) erasedTypeRef(ObjectClass)
- else {
- // implement new spec for erasure of refined types.
- val psyms = parents map (_.typeSymbol)
- def isUnshadowed(psym: Symbol) =
- !(psyms exists (qsym => (psym ne qsym) && (qsym isNonBottomSubClass psym)))
- val cs = parents.iterator.filter { p => // isUnshadowed is a bit expensive, so try classes first
- val psym = p.typeSymbol
- psym.isClass && !psym.isTrait && isUnshadowed(psym)
- }
- apply((if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next())
- }
+ intersectionErasure(parents)
case AnnotatedType(_, atp, _) =>
apply(atp)
case ClassInfoType(parents, decls, clazz) =>