Skip to content

Commit e88eb5b

Browse files
committed
Don't issue unreachable error messages for inlined code
Fixes #8967
1 parent 8d3083b commit e88eb5b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ object TypeTestsCasts {
354354
val isTrusted = tree.hasAttachment(PatternMatcher.TrustedTypeTestKey)
355355
if (!isTrusted && !checkable(expr.tpe, argType, tree.span))
356356
report.uncheckedWarning(i"the type test for $argType cannot be checked at runtime", expr.srcPos)
357-
transformTypeTest(expr, tree.args.head.tpe, flagUnrelated = true)
357+
transformTypeTest(expr, tree.args.head.tpe,
358+
flagUnrelated = enclosingInlineds.isEmpty) // if test comes from inlined code, dont't flag it even if it always false
358359
}
359360
else if (sym.isTypeCast)
360361
transformAsInstanceOf(erasure(tree.args.head.tpe))

tests/pos/i8967.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
inline def aToB[T,A,B](t:T,b:B): T|B = t match {
2+
case _:A => b
3+
case _:T => t
4+
}
5+
6+
@main def main() = aToB[Int, Double, String](1,"x")

0 commit comments

Comments
 (0)