[code-reflection] RFR: Define JavaRef top-type for all Java refs [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Apr 28 16:11:06 UTC 2025
On Mon, 28 Apr 2025 15:59:59 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> src/jdk.incubator.code/share/classes/jdk/incubator/code/type/JavaRef.java line 11:
>>
>>> 9: * can be resolved to an instance of {@link java.lang.reflect.Type Type}.
>>> 10: */
>>> 11: public sealed interface JavaRef
>>
>> Shouldn't `TypeVarRef` also extend from this?
>
> I always thought of it as just a java type element, correlated with `java.lang.reflect.TypeVariable` since that is what it resolves to.
>
> When thinking about this PR and more broadly I was pondering whether to rename `TypeVarRef` to `TypeVarRefType` or more verbosely as `TypeVariableType`, since i must admit to finding the `Ref` in `TypeVarRef` a little confusing as presumably it is referring to the type variable, but then `ClassType` refers to the class, etc.
> I always thought of it as just a java type element, correlated with `java.lang.reflect.TypeVariable` since that is what it resolves to.
>
> Why thinking about this PR and more broadly I was pondering whether to rename `TypeVarRef` to `TypeVarRefType` or more verbosely as `TypeVariableType`, since i must admit to to finding the `Ref` in `TypeVarRef` a little confusing as presumably it is referring to the type variable, but then `ClassType` refers to the class, etc.
Yeah - we went down the "ref" path because, well, it points to a declaration (of a type-variable). But I agree that `TypeVariable` or `TypeVariableType` is the better name. This is squarely a "type" - something that can be used where a type is expected, and something that can be turned into a `j.l.r.Type`
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/411#discussion_r2064010599
More information about the babylon-dev
mailing list