Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't issue unreachable error messages for inlined code #14871

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ object TypeTestsCasts {
val isTrusted = tree.hasAttachment(PatternMatcher.TrustedTypeTestKey)
if (!isTrusted && !checkable(expr.tpe, argType, tree.span))
report.uncheckedWarning(i"the type test for $argType cannot be checked at runtime", expr.srcPos)
transformTypeTest(expr, tree.args.head.tpe, flagUnrelated = true)
transformTypeTest(expr, tree.args.head.tpe,
flagUnrelated = enclosingInlineds.isEmpty) // if test comes from inlined code, dont't flag it even if it always false
}
else if (sym.isTypeCast)
transformAsInstanceOf(erasure(tree.args.head.tpe))
Expand Down
6 changes: 3 additions & 3 deletions project/scripts/cmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ fi
echo "testing that missing source file does not crash message rendering"
clear_out "$OUT"
clear_out "$OUT1"
cp tests/neg/i6371/A_1.scala $OUT/A.scala
cp tests/neg/i6371/B_2.scala $OUT/B.scala
cp tests/neg-macros/i6371/A_1.scala $OUT/A.scala
cp tests/neg-macros/i6371/B_2.scala $OUT/B.scala
"$SBT" "scalac $OUT/A.scala -d $OUT1"
rm $OUT/A.scala
"$SBT" "scalac -classpath $OUT1 -d $OUT1 $OUT/B.scala" > "$tmp" 2>&1 || echo "ok"
cat "$tmp" # for debugging
# cat "$tmp" # for debugging
grep -qe "B.scala:2:7" "$tmp"
grep -qe "This location contains code that was inlined from A.scala:3" "$tmp"

Expand Down
5 changes: 5 additions & 0 deletions tests/neg-macros/i6371/A_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import scala.quoted.*
object A {
inline def foo(a: Any): Unit = ${ crashOnInline }
def crashOnInline(using Quotes): Expr[Unit] = ???
}
File renamed without changes.
6 changes: 0 additions & 6 deletions tests/neg/i6371/A_1.scala

This file was deleted.

6 changes: 6 additions & 0 deletions tests/pos/i8967.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
inline def aToB[T,A,B](t:T,b:B): T|B = t match {
case _:A => b
case _:T => t
}

@main def main() = aToB[Int, Double, String](1,"x")