Skip to content

Commit b95c66e

Browse files
committed
Avoid spurious type test warning
This warning should trigger only for explicitly written type tests, never for type tests coming from a match. So far we did not notice this, since it triggered only for types that are known to be null, and there are very few of those so far (basically, just the primitive value types) and those types did not tend to be tested irrefutably in patterns.
1 parent e127bb4 commit b95c66e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ object TypeTestsCasts {
215215

216216
if (expr.tpe <:< testType)
217217
if (expr.tpe.isNotNull) {
218-
ctx.warning(TypeTestAlwaysSucceeds(foundCls, testCls), tree.sourcePos)
218+
if (!inMatch) ctx.warning(TypeTestAlwaysSucceeds(foundCls, testCls), tree.sourcePos)
219219
constant(expr, Literal(Constant(true)))
220220
}
221221
else expr.testNotNull

0 commit comments

Comments
 (0)