Skip to content

Commit d64620b

Browse files
committed
Fixes scala#2755, but leaving open to analyze issue ...
Fixes scala#2755, but leaving open to analyze issue raised by Paul. review by extempore.
1 parent f181a9b commit d64620b

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/compiler/scala/tools/nsc/transform/Erasure.scala

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,23 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast.
120120
// Compute the erasure of the intersection type with given `parents` according to new spec.
121121
private def intersectionErasure(parents: List[Type]): Type =
122122
if (parents.isEmpty) erasedTypeRef(ObjectClass)
123-
else {
124-
// implement new spec for erasure of refined types.
123+
else apply {
125124
val psyms = parents map (_.typeSymbol)
126-
def isUnshadowed(psym: Symbol) =
127-
!(psyms exists (qsym => (psym ne qsym) && (qsym isNonBottomSubClass psym)))
128-
val cs = parents.iterator.filter { p => // isUnshadowed is a bit expensive, so try classes first
129-
val psym = p.typeSymbol
130-
psym.isClass && !psym.isTrait && isUnshadowed(psym)
125+
if (psyms contains ArrayClass) {
126+
// treat arrays specially
127+
arrayType(
128+
intersectionErasure(
129+
parents filter (_.typeSymbol == ArrayClass) map (_.typeArgs.head)))
130+
} else {
131+
// implement new spec for erasure of refined types.
132+
def isUnshadowed(psym: Symbol) =
133+
!(psyms exists (qsym => (psym ne qsym) && (qsym isNonBottomSubClass psym)))
134+
val cs = parents.iterator.filter { p => // isUnshadowed is a bit expensive, so try classes first
135+
val psym = p.typeSymbol
136+
psym.isClass && !psym.isTrait && isUnshadowed(psym)
137+
}
138+
(if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next()
131139
}
132-
apply((if (cs.hasNext) cs else parents.iterator.filter(p => isUnshadowed(p.typeSymbol))).next())
133140
}
134141

135142
def apply(tp: Type): Type = {

0 commit comments

Comments
 (0)