diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index e15593480b00..4595720091b2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -1069,7 +1069,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) { em"""cannot reduce delegate match with | patterns : ${tree.cases.map(patStr).mkString("\n ")}""" else - em"""cannot reduce delegate match with + em"""cannot reduce inline match with | scrutinee: $sel : ${selType} | patterns : ${tree.cases.map(patStr).mkString("\n ")}""" errorTree(tree, msg) diff --git a/tests/neg/cannot-reduce-delegate-match.check b/tests/neg/cannot-reduce-delegate-match.check new file mode 100644 index 000000000000..c46031f5b5ba --- /dev/null +++ b/tests/neg/cannot-reduce-delegate-match.check @@ -0,0 +1,8 @@ +-- Error: tests/neg/cannot-reduce-delegate-match.scala:4:13 ------------------------------------------------------------ +4 | delegate match { // error + | ^ + | cannot reduce delegate match with + | patterns : case evidence$1 @ _:Int + | This location is in code that was inlined at cannot-reduce-delegate-match.scala:13 +5 | case _: Int => +6 | } diff --git a/tests/neg/cannot-reduce-delegate-match.scala b/tests/neg/cannot-reduce-delegate-match.scala new file mode 100644 index 000000000000..e4286d831b40 --- /dev/null +++ b/tests/neg/cannot-reduce-delegate-match.scala @@ -0,0 +1,14 @@ +object Test { + + inline def bar() = + delegate match { // error + case _: Int => + } + + { + delegate for Int = 9 + bar() + } + + bar() +} \ No newline at end of file diff --git a/tests/neg/cannot-reduce-inline-match.check b/tests/neg/cannot-reduce-inline-match.check new file mode 100644 index 000000000000..8f063f0003d2 --- /dev/null +++ b/tests/neg/cannot-reduce-inline-match.check @@ -0,0 +1,11 @@ +-- Error: tests/neg/cannot-reduce-inline-match.scala:3:13 -------------------------------------------------------------- +3 | inline x match { // error + | ^ + | cannot reduce inline match with + | scrutinee: { + | "f" + | } : String("f") + | patterns : case _:Int + | This location is in code that was inlined at cannot-reduce-inline-match.scala:9 +4 | case _: Int => +5 | } diff --git a/tests/neg/cannot-reduce-inline-match.scala b/tests/neg/cannot-reduce-inline-match.scala new file mode 100644 index 000000000000..b9b0ad0d5dda --- /dev/null +++ b/tests/neg/cannot-reduce-inline-match.scala @@ -0,0 +1,11 @@ +object Test { + inline def foo[T](x: T) = + inline x match { // error + case _: Int => + } + + foo(4) + + foo("f") + +} \ No newline at end of file