-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Quoted API has broken impl for fields
(case fields
/ declared fields
/ ...)
#22584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
println(s"sym.raw: ${sym.raw}")
println(s"sym.raw.isValDef: ${sym.raw.isValDef}")
println(s"sym.raw.isDefDef: ${sym.raw.isDefDef}")
println(s"sym.raw.tree: ${sym.raw.tree}")
|
🤔 I just tried reverting back to |
Please provide a fully reproducible minimization |
oxygen.meta.tmp.Caller.scalapackage oxygen.meta.tmp
import Types.*
object Caller extends scala.App {
Macros.myMacro[MyClass1]
} oxygen.meta.tmp.Types.scalapackage oxygen.meta.tmp
object Types {
final case class MyClass1(
int: Int,
string: String,
boolean: Boolean,
)
} oxygen.meta.tmp.Macros.scalapackage oxygen.meta.tmp
import scala.quoted.*
object Macros {
inline def myMacro[A]: Unit = ${ myMacroImpl[A] }
private def myMacroImpl[A](using quotes: Quotes, tpe: Type[A]): Expr[Unit] = {
import quotes.reflect.*
val typeRepr = TypeRepr.of[A]
val typeSymbol = typeRepr.typeSymbol
val caseFieldSymbols: List[Symbol] = typeSymbol.caseFields
val caseFieldValDefs: List[ValDef] =
caseFieldSymbols.map {
_.tree match {
case valDef: ValDef => valDef
case _ => report.errorAndAbort("???")
}
}
println(caseFieldValDefs)
'{ () }
}
} |
I think I have isolated the source as a part of reducing this... scalacOptions ++= Seq("-Yretain-trees"), |
This is not a bug: https://dotty.epfl.ch/api/scala/quoted/Quotes$reflectModule$SymbolMethods.html#tree-d26 |
@prolativ this
|
Sorry, you're right. That's really strange |
Compiler version
3.6.3
note, was not an issue before I bumped from
3.3.0
edit
: I reverted to3.3.0
, and apparently it was still an issue, actuallyMinimized code
Output
Expectation
MatchError
3.3.0
, these were returning asValDef
Code I was using:
The text was updated successfully, but these errors were encountered: