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 @@ -19,6 +19,11 @@ import reporting.diagnostic.messages._
19
19
* This is a generalized solution to raising an error on unreachable match
20
20
* cases and warnings on other statically known results of `isInstanceOf`.
21
21
*
22
+ * This phase also warns if the erased type parameter of a parameterized type
23
+ * is used in a match where it would be erased to `Object` or if the
24
+ * typeparameters are removed. Both of these cases could cause surprising
25
+ * behavior for the users.
26
+ *
22
27
* Steps taken:
23
28
*
24
29
* 1. `evalTypeApply` will establish the matrix and choose the appropriate
@@ -128,6 +133,8 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
128
133
129
134
val selClassNonFinal = selClass && ! (selector.typeSymbol is Final )
130
135
val selFinalClass = selClass && (selector.typeSymbol is Final )
136
+
137
+ /** Check if the selector's potential type parameters will be erased, and if so warn */
131
138
val selTypeParam = tree.args.head.tpe.widen match {
132
139
case tp @ AppliedType (tycon, args) =>
133
140
// 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