Skip to content

Commit 199fd9d

Browse files
committed
Constrain anyValArray check to primitives
1 parent 3dd2eb7 commit 199fd9d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/transform/IsInstanceOfEvaluator.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
133133
val selClassNonFinal = selClass && !(selector.typeSymbol is Final)
134134
val selFinalClass = selClass && (selector.typeSymbol is Final)
135135

136-
/** Check if the selector's potential type parameters will be erased, and if so warn */
136+
// Check if the selector's potential type parameters will be erased, and if so warn
137137
val selTypeParam = tree.args.head.tpe.widen match {
138138
case tp @ AppliedType(_, arg :: _) =>
139-
// If the type is `Array[X]` where `X` extends AnyVal
140-
val anyValArray = tp.isRef(defn.ArrayClass) && arg.derivesFrom(defn.AnyValClass)
139+
// If the type is `Array[X]` where `X` is a primitive value
140+
// class. In the future, when we have a solid implementation of
141+
// Arrays of value classes, we might be able to relax this check.
142+
val anyValArray = tp.isRef(defn.ArrayClass) && arg.typeSymbol.isPrimitiveValueClass
141143
// param is: Any | AnyRef | java.lang.Object
142144
val topType = defn.ObjectType <:< arg
143145
// has @unchecked annotation to suppress warnings

0 commit comments

Comments
 (0)