Skip to content

Commit 0e6dc2e

Browse files
committed
Add regression test
Closes #6991
1 parent 75bacdb commit 0e6dc2e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/neg-macros/i6991.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- [E050] Type Error: tests/neg-macros/i6991.scala:11:14 ---------------------------------------------------------------
2+
11 | case '{($x: Foo)($bar: String)} => '{"Hello World"} // error
3+
| ^^^^^^^
4+
| expression does not take parameters
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E008] Not Found Error: tests/neg-macros/i6991.scala:12:23 ----------------------------------------------------------
8+
12 | case '{($x: Foo).apply($bar: String)} => '{"Hello World"} // error
9+
| ^^^^^^^^^^^^^^^
10+
| value apply is not a member of macros.Foo

tests/neg-macros/i6991.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted._
2+
3+
object macros {
4+
inline def mcr(x: => Any): Any = ${mcrImpl('x)}
5+
6+
class Foo // { def apply(str: String) = "100" }
7+
class Bar { def apply(str: String) = "100" }
8+
9+
def mcrImpl(body: Expr[Any])(using ctx: Quotes): Expr[Any] = {
10+
body match {
11+
case '{($x: Foo)($bar: String)} => '{"Hello World"} // error
12+
case '{($x: Foo).apply($bar: String)} => '{"Hello World"} // error
13+
case '{($x: Bar)($bar: String)} => '{"Hello World"}
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)