-
Notifications
You must be signed in to change notification settings - Fork 1.1k
classSymbol fullname not consistent with class name for inner classes #10933
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
Comments
The name of a symbol and the name of a type are two different things, we probably can't conflate them in the Reflect API. In most cases, if a symbol defines a class, then going through symbol -> tree -> type -> name should give a name that in most cases resolves back to the class. IIRC there are still edge-cases where it won't, such as names that contain dots. /cc @nicolasstucki |
@abgruszecki Could you please clarify the tree -> type -> name relationship? I've tried |
Ah, I just took a look at the API and it doesn't look like what I had in mind is possible in Reflect, it was a path we could take inside the compiler. I'll need to experiment a bit. |
Thanks a lot for taking some time to look at it. To give some more background, my ultimate goal is somehow to replace the usage of Scala 2's TypeParametersInfo(
clazz = classOf[Seq],
typeArgs = Seq(
TypeParametersInfo(
clazz = classOf[Int],
typeArgs = Nil
)
)
) If I've got the class full names using macros and the implicit But maybe you can think of a totally different way to achieve this goal 😄 |
Relates to #11161 |
For anyone interested, I've solved my initial use case using a macro that gives me a |
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
Consider the following macro:
And the following usage (as a test but doesn't matter) :
Output
For inner classes, the name given by the macro is different of the actual class name.
Expectation
I expected the
TypeRepr.of[T1].classSymbol.get.fullName
to give the same name as wouldclassOf[T1].getName
.To give some background, I'm later using the class name with
Class.forName(name)
and it fails forClass.forName("TestObject$.ObjectInnerClass")
for instance.If that's an expected behavior, what would be the way from
TypeRepr.of[T1]
to get the class name that can later be used to retrieve the actual class?The text was updated successfully, but these errors were encountered: