File tree 1 file changed +7
-0
lines changed
compiler/src/dotty/tools/dotc/transform
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ import reporting.diagnostic.messages._
22
22
* This is a generalized solution to raising an error on unreachable match
23
23
* cases and warnings on other statically known results of `isInstanceOf`.
24
24
*
25
+ * This phase also warns if the erased type parameter of a parameterized type
26
+ * is used in a match where it would be erased to `Object` or if the
27
+ * typeparameters are removed. Both of these cases could cause surprising
28
+ * behavior for the users.
29
+ *
25
30
* Steps taken:
26
31
*
27
32
* 1. evalTypeApply will establish the matrix and choose the appropriate
@@ -127,6 +132,8 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
127
132
128
133
val selClassNonFinal = selClass && ! (selector.typeSymbol is Final )
129
134
val selFinalClass = selClass && (selector.typeSymbol is Final )
135
+
136
+ /** Check if the selector's potential type parameters will be erased, and if so warn */
130
137
val selTypeParam = tree.args.head.tpe.widen match {
131
138
case tp @ AppliedType (tycon, args) =>
132
139
// If the type is Array[X] where x extends AnyVal, this shouldn't yield a warning:
You can’t perform that action at this time.
0 commit comments