Skip to content

Commit 30d61ab

Browse files
felixmulderodersky
authored andcommitted
Add comments to Phase explaining warnings
1 parent ab75fb5 commit 30d61ab

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
@@ -22,6 +22,11 @@ import reporting.diagnostic.messages._
2222
* This is a generalized solution to raising an error on unreachable match
2323
* cases and warnings on other statically known results of `isInstanceOf`.
2424
*
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+
*
2530
* Steps taken:
2631
*
2732
* 1. evalTypeApply will establish the matrix and choose the appropriate
@@ -127,6 +132,8 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
127132

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

0 commit comments

Comments
 (0)