Open DmytroMitin opened 2 years ago
Using Scala 3.4.1 the example type checks and works as expected. Close?
[~]$ scala-cli
Welcome to Scala 3.4.1 (21.0.3, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> import scala.quoted.*
|
| object Macro {
| inline def fooMacro[A, B]: Unit = ${fooMacroImpl[A, B]}
|
| def fooMacroImpl[A: Type, B: Type](using Quotes): Expr[Unit] = {
| import quotes.reflect.*
|
| val res = '{tag[A, B]} match {
| case '{
| type a
| type b <: `a`
| tag[`a`, `b`]
| } => '{foo[a, b]}
| }
|
| println(res.show)
|
| res
| }
|
| def tag[A, B] = ???
|
| def foo[A, B <: A]: Unit = ???
| }
// defined object Macro
scala> Macro.fooMacro[String, String]
rs$line$1.Macro.foo[b, java.lang.String]
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
at rs$line$1$Macro$.foo(rs$line$1:24)
... 30 elided
Or is this the wrong output?
scala> Macro.fooMacro[AnyVal, Int]
rs$line$1.Macro.foo[scala.AnyVal | b, scala.Int]
seems odd that b
is still there.
Compiler version
3.1.3 3.2.2-RC1-bin-20220925-562ab85-NIGHTLY
Minimized code
Output
Expectation
The macro should typecheck.
Comment
If I replace
=> '{foo[a, b]}
with=> '{foo[a, b & a]}
thenMacro.fooMacro[AnyVal, Int]
typechecks but printsinstead of
Can be similar to
https://github.com/lampepfl/dotty/issues/13527
https://github.com/lampepfl/dotty/issues/14708
Motivated by https://stackoverflow.com/questions/70311751/what-scala-3-syntax-can-match-on-a-type-and-its-type-parameters-in-the-context-o