File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ -- [E007] Type Mismatch Error: tests/neg-macros/i22616b.scala:17:18 ----------------------------------------------------
2+ 17 | case '{ Foo($y: t) } => // error
3+ | ^^^^^
4+ | Found: t
5+ | Required: String
6+ |
7+ | longer explanation available when compiling with `-explain`
8+ -- [E006] Not Found Error: tests/neg-macros/i22616b.scala:18:19 --------------------------------------------------------
9+ 18 | '{type S = t; ()} // error
10+ | ^
11+ | Not found: type t
12+ |
13+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change 1+ // This test illustrates a current limitation of quoted pattern type variables,
2+ // which has been discussed in https://github.com/scala/scala3/issues/22616#issuecomment-3012534064:
3+ // These type variables do not have bound in general (see `typedQuotedTypeVar`),
4+ // so they might not conform to the expected type. Here, `t` does not conform
5+ // to `String`.
6+
7+ import scala .quoted .{FromExpr , Expr , Quotes }
8+
9+ case class Foo (x : String )
10+
11+ object Macro :
12+ inline def myMacro (): Unit =
13+ $ { myMacroImpl(' {Foo (" hello" )}) }
14+
15+ def myMacroImpl (x : Expr [Foo ])(using Quotes ): Expr [Unit ] =
16+ x match
17+ case ' { Foo ($y : t) } => // error
18+ ' {type S = t; ()} // error
19+ case _ =>
20+ println(" not a foo" )
21+
22+ ' {()}
You can’t perform that action at this time.
0 commit comments