Closed
Description
minimized code
Macro definition:
import scala.quoted._
object Macros {
inline def m[R](sym: Symantics[R]) : R = ${ mImpl[R]('{sym}) }
def mImpl[R: Type](sym: Expr[Symantics[R]]) given (qctx: QuoteContext): Expr[R] = '{
$sym.Meth(42)
}
}
trait Symantics[R] {
def Meth(exp: Int): R
def Meth(): R
}
Use:
import scala.quoted._
import Macros._
object Test {
def main(args: Array[String]): Unit = {
val sym = new Symantics[Int] {
def Meth(exp: Int): Int = exp
def Meth(): Int = 42
}
val test = m[Int](sym)
}
}
expectation
Overloading should work. Instead it reports:
8 | $sym.Meth(42)
| ^^^^^^^^^^^^
| wrong number of arguments at <no phase> for (): Int: ((): Int)(sym.Meth), expected: 0, found: 1
| This location is in code that was inlined at Test_2.scala:13
If I remove the macro call it works (TASTy problem), if the Symantics
is not parametric it also works. I don't think that it directly related to #7022 but it is definitely in the same area (@smarter WDYT?). BTW, the <no phase>
in the error is also a bug I assume.