Skip to content

Commit c396e96

Browse files
committed
Ignore BoundedWildcardType in erasure type map
This case can be triggered as illustrated in the test.
1 parent 2fec08b commit c396e96

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/reflect/scala/reflect/internal/transform/Erasure.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ trait Erasure {
161161
}
162162
if (newParents eq parents) tp
163163
else ClassInfoType(newParents, decls, clazz)
164+
165+
// can happen while this map is being used before erasure (e.g. when reasoning about sam types)
166+
// the regular mapOver will cause a class cast exception because TypeBounds don't erase to TypeBounds
167+
case _: BoundedWildcardType => tp // skip
168+
164169
case _ =>
165170
mapOver(tp)
166171
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Test {
2+
trait Q[T] {
3+
def toArray[T](x: Array[T]): Array[T]
4+
def toArray(): Array[T]
5+
}
6+
7+
def crashTyper: Array[_] = {
8+
val x : Q[_] = ???
9+
x.toArray // crashes while doing overload resolution
10+
}
11+
}

0 commit comments

Comments
 (0)