Open
Description
Compiler version
Scala 3
Output
I get this
Exception occurred while executing macro expansion.
[error] |scala.MatchError: DefDef(given_FromData ...
...
at dotty.tools.dotc.quoted.reflect.FromSymbol$.valDefFromSym(FromSymbol.scala:50)
[error] | at dotty.tools.dotc.quoted.reflect.FromSymbol$.definitionFromSym(FromSymbol.scala:22)
[error] | at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.tree(QuotesImpl.scala:2528)
[error] | at scala.quoted.runtime.impl.QuotesImpl$reflect$SymbolMethods$.tree(QuotesImpl.scala:2528)
where
given FromData[...] = (d: Data) => {...}
Looks like this code is not correct:
def definitionFromSym(sym: Symbol)(using Context): tpd.Tree = {
assert(sym.exists, "Cannot get tree of no symbol")
assert(!sym.is(Package), "Cannot get tree of package symbol")
if (sym.isClass) classDef(sym.asClass)
else if (sym.isType && sym.is(Case)) typeBindFromSym(sym.asType)
else if (sym.isType) typeDefFromSym(sym.asType)
else if (sym.is(Method)) defDefFromSym(sym.asTerm)
else if (sym.is(Case, butNot = ModuleVal | EnumVal)) bindFromSym(sym.asTerm)
else valDefFromSym(sym.asTerm)
}
I assume it probably should be this instead, but I'm not sure
else if (sym.isOneOf(GivenMethod)) defDefFromSym(sym.asTerm)