You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[warn] ./Macro.scala:10:12
[warn] the typetestfor x$2.reflect.Literal cannot be checked at runtime because it refers to an abstracttypemember or typeparameter
[warn] caseLiteral(_) => {}
[warn] ^
[error] ./Main.scala:2:3
[error] Exception occurred while executing macro expansion.
[error] java.lang.ClassCastException:classscala.quoted.runtime.impl.ExprImpl cannot be cast to classdotty.tools.dotc.ast.Trees$Literal (scala.quoted.runtime.impl.ExprImpl and dotty.tools.dotc.ast.Trees$Literal are in unnamed module of loader java.net.URLClassLoader@7f83ad80)
[error] at scala.quoted.runtime.impl.QuotesImpl$reflect$Literal$.unapply(QuotesImpl.scala:572)
[error] at Macro$.fooImpl(Macro.scala:10)
[error]
[error] Macro.foo("abcd")
Expectation
This code hides a user's error that might not be that easy to spot (str match instead of str.asTerm match), nevertheless this behaviour seems unexpected to me. IMO if case Literal(_) cannot be matched, there should be no exception and the fallback case _ branch of the match should be used and the entire compilation should succeed.
The text was updated successfully, but these errors were encountered:
Compiler version
3.6.0-RC1-bin-20240918-be10596-NIGHTLY and anything before
Minimized code
Macro.scala
:Main.scala
:Output
Compilation fails with:
Expectation
This code hides a user's error that might not be that easy to spot (
str match
instead ofstr.asTerm match
), nevertheless this behaviour seems unexpected to me. IMO ifcase Literal(_)
cannot be matched, there should be no exception and the fallbackcase _
branch of the match should be used and the entire compilation should succeed.The text was updated successfully, but these errors were encountered: