Skip to content

Commit 71811ad

Browse files
authored
Merge pull request #6771 from dotty-staging/fix-inline-match-message
Fix error message for unreducible inline match
2 parents 8149abc + e3d3927 commit 71811ad

File tree

5 files changed

+45
-1
lines changed

5 files changed

+45
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
10691069
em"""cannot reduce delegate match with
10701070
| patterns : ${tree.cases.map(patStr).mkString("\n ")}"""
10711071
else
1072-
em"""cannot reduce delegate match with
1072+
em"""cannot reduce inline match with
10731073
| scrutinee: $sel : ${selType}
10741074
| patterns : ${tree.cases.map(patStr).mkString("\n ")}"""
10751075
errorTree(tree, msg)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/neg/cannot-reduce-delegate-match.scala:4:13 ------------------------------------------------------------
2+
4 | delegate match { // error
3+
| ^
4+
| cannot reduce delegate match with
5+
| patterns : case evidence$1 @ _:Int
6+
| This location is in code that was inlined at cannot-reduce-delegate-match.scala:13
7+
5 | case _: Int =>
8+
6 | }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
3+
inline def bar() =
4+
delegate match { // error
5+
case _: Int =>
6+
}
7+
8+
{
9+
delegate for Int = 9
10+
bar()
11+
}
12+
13+
bar()
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Error: tests/neg/cannot-reduce-inline-match.scala:3:13 --------------------------------------------------------------
2+
3 | inline x match { // error
3+
| ^
4+
| cannot reduce inline match with
5+
| scrutinee: {
6+
| "f"
7+
| } : String("f")
8+
| patterns : case _:Int
9+
| This location is in code that was inlined at cannot-reduce-inline-match.scala:9
10+
4 | case _: Int =>
11+
5 | }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test {
2+
inline def foo[T](x: T) =
3+
inline x match { // error
4+
case _: Int =>
5+
}
6+
7+
foo(4)
8+
9+
foo("f")
10+
11+
}

0 commit comments

Comments
 (0)