Skip to content

ClassInfo exposed via a typeMember call on a sealedType/enum #22052

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

Closed
jchyb opened this issue Nov 29, 2024 · 2 comments
Closed

ClassInfo exposed via a typeMember call on a sealedType/enum #22052

jchyb opened this issue Nov 29, 2024 · 2 comments
Labels
area:metaprogramming:reflection Issues related to the quotes reflection API itype:bug

Comments

@jchyb
Copy link
Contributor

jchyb commented Nov 29, 2024

Compiler version

main (10bb2e6)

Minimized code

Macro_1.scala

import scala.quoted.*

object Macros {
  def testImpl(using Quotes): Expr[Unit] = {
    import quotes.reflect.*

    val barSymbol = TypeRepr.of[domain.Bar].typeSymbol
    val typeMemberClassInfo = TypeRepr.of[domain.Foo].memberType(barSymbol)
    println(typeMemberClassInfo)

    '{()}
  }

  inline def test: Unit = ${ testImpl }
}

object domain {
  sealed trait Foo
  case class Bar() extends Foo
}

Test_2.scala:

@main def main = Macros.test

Output

ClassInfo(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class domain$)), class Bar, List(TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object), TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class domain$)),trait Foo), TypeRef(TermRef(TermRef(NoPrefix,object _root_),object scala),trait Product), TypeRef(ThisType(TypeRef(NoPrefix,module class io)),trait Serializable)))

Expectation

ClassInfo should never be exposed in the quotes reflection API. directly calling TypeRepr.of[domain.Bar], we get TypeRef(TermRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),domain),Bar), which is a result I would expect there instead of ClassInfo.

@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 Nov 29, 2024
@jchyb
Copy link
Contributor Author

jchyb commented Nov 29, 2024

Related: #15643

@jchyb
Copy link
Contributor Author

jchyb commented Nov 29, 2024

Duplicate of #13319

@jchyb jchyb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2024
@jchyb jchyb marked this as a duplicate of #13319 Nov 29, 2024
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

No branches or pull requests

1 participant