-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:experimentalarea:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesitype:bug
Description
Compiler version
main, any after 3.6.0
Minimized code
@scala.annotation.experimental @main def main() =
testMacro([B] => (a : B, b : B) => (a, b))
import scala.quoted.*
import scala.language.experimental.quotedPatternsWithPolymorphicFunctions
inline def testMacro(inline body: Any) = ${test('body)}
def test(outsideBody: Expr[Any])(using Quotes): Expr[Unit] =
val insideBody = '{[B] => (a : B, b : B) => (a, b)}
insideBody match // outsideBody works
case '{ [A] => (x : A, y : A) => $b[A](x, y): (A, A) } => println("ok")
'{()}
Output
-- Error: a2.scala:3:11 --------------------------------------------------------
3 | testMacro([B] => (a : B, b : B) => (a, b))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|Exception occurred while executing macro expansion.
|scala.MatchError: scala.quoted.runtime.impl.ExprImpl@14ba7f15 (of class scala.quoted.runtime.impl.ExprImpl)
| at a$package$.test(a.scala:10)
|
|-----------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|This location contains code that was inlined from a.scala:4
4 |inline def testMacro(inline body: Any) = ${test('body)}
| ^^^^^^^^^^^^^^
-----------------------------------------------------------------------------
Expectation
Should compile, as both insideBody
and outsideBody
have the exact same shape when printed out:
{
def $anonfun[B](a: B, b: B): scala.Tuple2[B, B] = scala.Tuple2.apply[B, B](a, b)
$anonfun
}
Metadata
Metadata
Assignees
Labels
area:experimentalarea:metaprogramming:quotesIssues related to quotes and splicesIssues related to quotes and splicesitype:bug