File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments