Skip to content

Commit 0456326

Browse files
committed
Add comments to Phase explaining warnings
1 parent 0e9b1ba commit 0456326

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import reporting.diagnostic.messages._
1919
* This is a generalized solution to raising an error on unreachable match
2020
* cases and warnings on other statically known results of `isInstanceOf`.
2121
*
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+
*
2227
* Steps taken:
2328
*
2429
* 1. `evalTypeApply` will establish the matrix and choose the appropriate
@@ -128,6 +133,8 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
128133

129134
val selClassNonFinal = selClass && !(selector.typeSymbol is Final)
130135
val selFinalClass = selClass && (selector.typeSymbol is Final)
136+
137+
/** Check if the selector's potential type parameters will be erased, and if so warn */
131138
val selTypeParam = tree.args.head.tpe.widen match {
132139
case tp @ AppliedType(tycon, args) =>
133140
// If the type is Array[X] where x extends AnyVal, this shouldn't yield a warning:

0 commit comments

Comments
 (0)