Closed
Description
Compiler version
Works in 3.3.1-RC4
Fails in 3.3.2-RC nightly
Bisect points to 3c07379
Minimized code
import scala.quoted.*
case class QueryMeta[T](map: Map[String, String])
object QueryMeta:
given [T]: FromExpr[QueryMeta[T]] = new FromExpr[QueryMeta[T]]:
def unapply(expr: Expr[QueryMeta[T]])(using q: Quotes): Option[QueryMeta[T]] =
import q.reflect.*
expr match
case '{ QueryMeta(${ map }: Map[String, String]) } =>
map.value.map(QueryMeta[T].apply)
case _ =>
None
Output
-- Error: /Users/wmazur/projects/dotty/bisect/main.scala:10:16 -----------------
10 | case '{ QueryMeta(${ map }: Map[String, String]) } =>
| ^^^^^^^^^
|Reference to T within quotes requires a given scala.quoted.Type[T] in scope.
|
1 error found
Workaround
case '{ QueryMeta[t](${ map }: Map[String, String]) } =>
Expectation
It makes sense that quotes it fails when type parameter is failing, but the error message seems to not be very pricise here. It would make sense to make this code compile in 3.3.x for LTS source compatibility, and change semantics in 3.4.x