Skip to content

Symbol.typeMembers can return empty Symbols on union type aliases #22483

Open
@jchyb

Description

@jchyb

Compiler version

main, 3.3.5, probably any

Minimized code

(minimisation partially stolen from #22472)

@main def Test: Unit = {
  class FooSmall[A, B] { type C; type D }
  class FooLarge[A, B, C] { type D; type E }
  type FooUnion[A, B] = FooSmall[A, B] | FooLarge[A, B, B]

  println(Macro.typeMembers[FooUnion])
}
import scala.quoted.*

object Macro {
  transparent inline def typeMembers[T <: AnyKind]: String = ${ typeMembersImpl[T] }

  def typeMembersImpl[T <: AnyKind: Type](using quotes: Quotes): Expr[String] = {
    import quotes.reflect.*
    Expr(TypeRepr.of[T].typeSymbol.typeMembers.toString)
  }
}

Output

List(val <none>, val <none>, val <none>, val <none>)

Expectation

Return either an empty list, or actually existing Symbols, not sure (probably the second one).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions