-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add reflect TypeRepr.substituteTypes #13166
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
Conversation
3bdb053
to
937aa82
Compare
Interesting, thanks ... is there a snapshot build? |
Up ? |
That's seems ok for me: It would be nice to merge it, to remove this blocker. |
I still need some tests for this feature. @cchantep could you help me create a small self contained example that captures your use case? |
@nicolasstucki I don't see how to directly update the existing test (BTW I think it lakes a proper documentation). inline def testSubst: Unit = ${ testSubstImpl }
def testSubstImpl(using q: Quotes): Expr[Unit] = {
import q.reflect.*
val intTpe = TypeRepr.of[Int]
val strOptTpe = TypeRepr.of[Option[String]]
val tpeArgs: List[TypeRepr] = strOptTpe match {
case AppliedType(_, args) => args
case _ => List.empty[TypeRepr]
}
val intOptTpe = strOptTpe.substituteTypes(
tpeArgs.map(_.typeSymbol), List(intTpe))
val repr = s"${strOptTpe.show} to ${intOptTpe.show}"
'{
println(${Expr(repr)})
}
} Expected printed result:
|
937aa82
to
4873ebc
Compare
Flaky unrelated tests ? |
4873ebc
to
79c66d6
Compare
79c66d6
to
7293af1
Compare
No, a tab auto-complete test that changed |
👍 |
No description provided.