Skip to content

Fix error message for unreducible inline match #6771

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

Merged
merged 1 commit into from
Jul 1, 2019
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/cannot-reduce-delegate-match.check
Original file line number Diff line number Diff line change
@@ -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 | }
14 changes: 14 additions & 0 deletions tests/neg/cannot-reduce-delegate-match.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object Test {

inline def bar() =
delegate match { // error
case _: Int =>
}

{
delegate for Int = 9
bar()
}

bar()
}
11 changes: 11 additions & 0 deletions tests/neg/cannot-reduce-inline-match.check
Original file line number Diff line number Diff line change
@@ -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 | }
11 changes: 11 additions & 0 deletions tests/neg/cannot-reduce-inline-match.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Test {
inline def foo[T](x: T) =
inline x match { // error
case _: Int =>
}

foo(4)

foo("f")

}