Skip to content
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

memberType pointing to a nested class exposes ClassInfo #22395

Open
jchyb opened this issue Jan 17, 2025 · 0 comments · May be fixed by #22402
Open

memberType pointing to a nested class exposes ClassInfo #22395

jchyb opened this issue Jan 17, 2025 · 0 comments · May be fixed by #22402
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug

Comments

@jchyb
Copy link
Contributor

jchyb commented Jan 17, 2025

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

@jchyb jchyb added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:metaprogramming:reflection Issues related to the quotes reflection API and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 17, 2025
@jchyb jchyb linked a pull request Jan 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant