Skip to content

Commit 4421d12

Browse files
committed
Handle opaque aliases of arrays in Space erase
1 parent cae6786 commit 4421d12

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ object SpaceEngine {
449449
*
450450
* @param inArray whether `tp` is a type argument to `Array`
451451
* @param isValue whether `tp` is the type which match against values
452+
* @param isTyped whether `tp` is the type from a `Typed` tree
452453
*
453454
* If `isValue` is true, then pattern-bound symbols are erased to its upper bound.
454455
* This is needed to avoid spurious unreachable warnings. See tests/patmat/i6197.scala.
@@ -459,7 +460,7 @@ object SpaceEngine {
459460
WildcardType
460461

461462
case tp @ AppliedType(tycon, args) =>
462-
val inArray = tycon.isRef(defn.ArrayClass)
463+
val inArray = tycon.isRef(defn.ArrayClass) || tp.translucentSuperType.isRef(defn.ArrayClass)
463464
val args2 =
464465
if isTyped && !inArray then args.map(_ => WildcardType)
465466
else args.map(arg => erase(arg, inArray = inArray, isValue = false))

tests/pos/i18364.Tup.scala

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Capturing the regression will implementing the fix for i18364
2+
// That broke in CI, "case _" "Unreachable case except for null"
3+
// Because IArray is an opaque alias of Array
4+
object Tup:
5+
/** Convert an immutable array into a tuple of unknown arity and types */
6+
def fromIArray[T](xs: IArray[T]): Tuple =
7+
val xs2: IArray[Object] = xs match
8+
case xs: IArray[Object] @unchecked => xs
9+
case _ => xs.map(_.asInstanceOf[Object])
10+
runtime.Tuples.fromIArray(xs2)

0 commit comments

Comments
 (0)