Skip to content

Quoted API has broken impl for fields (case fields / declared fields / ...) #22584

Open
@Kalin-Rudnicki

Description

Compiler version

3.6.3
note, was not an issue before I bumped from 3.3.0
edit: I reverted to 3.3.0, and apparently it was still an issue, actually

Minimized code

TypeRepr.of[A].typeSymbol.caseFields.map(_.tree)
TypeRepr.of[A].typeSymbol.declaredFields.map(_.tree)

Output

[error]    |Exception occurred while executing macro expansion.
[error]    |scala.MatchError: DefDef(int,List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)],EmptyTree) (of class dotty.tools.dotc.ast.Trees$DefDef)

Expectation

  1. Expect that compiler wont throw MatchError
  2. In 3.3.0, these were returning as ValDef

Code I was using:

typeSymbol: Symbol = typeRepr.typeSymbol
caseFieldSymbols: List[Symbol] = typeSymbol.caseFields

caseFieldSymbols.traverse { sym =>
            sym.tree match {
              case valDef: ValDef => valDef.asRight
              case _      => s"Somehow not a `ValDef`: ${sym.fullName}".asLeft
            }

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions