summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-01-13 16:27:40 +0000
committerMartin Odersky <odersky@gmail.com>2010-01-13 16:27:40 +0000
commitd64620b254491b38b7cc6ce600ba2256ce5ef6a8 (patch)
tree0c8ec4462f3fdbaa9db522e020bc442e4e3e3171 /src/compiler
parentf181a9be2af25ae20f89ab983018f34e6884d415 (diff)
downloadscala-d64620b254491b38b7cc6ce600ba2256ce5ef6a8.tar.gz
scala-d64620b254491b38b7cc6ce600ba2256ce5ef6a8.tar.bz2
scala-d64620b254491b38b7cc6ce600ba2256ce5ef6a8.zip
Fixes #2755, but leaving open to analyze issue ...
Fixes #2755, but leaving open to analyze issue raised by Paul. review by extempore.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index de9dadbd1f..e92ba64469 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -120,16 +120,23 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
// 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.
+ else apply {
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)
+ if (psyms contains ArrayClass) {
+ // treat arrays specially
+ arrayType(
+ intersectionErasure(
+ parents filter (_.typeSymbol == ArrayClass) map (_.typeArgs.head)))
+ } else {
+ // implement new spec for erasure of refined types.
+ 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)
+ }
+ (if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next()
}
- apply((if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next())
}
def apply(tp: Type): Type = {