Skip to content

memberType pointing to a nested class exposes ClassInfo #22395

Open
@jchyb

Description

@jchyb

Compiler version

any, main

Minimized code

import scala.quoted._

inline def test() = ${testImpl}
def testImpl(using Quotes) = {
  import quotes.reflect._
  val fooSymbol = TypeRepr.of[Foo[Int]].typeSymbol
  val nestedSymbol = fooSymbol.typeMember("Nested")

  println(TypeRepr.of[Foo[Int]].memberType(nestedSymbol))

  '{()}
}


trait Foo[X]:
  sealed abstract class Nested extends Foo[Int]
@main def Test = test()

Output

ClassInfo(AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),Foo),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Int))), class Nested, List(TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),trait Foo),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)))))

Expectation

ClassInfo should not be exposed in the Quotes reflect API, instead we should get a TypeRef, like. in other similar situations:

TypeRef(AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),Foo),List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),Int))),class Nested)

Found by @Florian3k, fix needed for Scaladoc

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