[code-reflection] RFR: Enable pattern matching for JavaType hierarchy
Paul Sandoz
psandoz at openjdk.org
Fri Apr 26 19:40:56 UTC 2024
On Fri, 26 Apr 2024 17:50:43 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> The `JavaType` hierarchy has now several types under it:
>
> * `ClassType`
> * `ArrayType`
> * `PrimitiveType`
> * `TypeVarRef`
> * `WildcardType`
>
> All these types are `public`, except `PrimitiveType`. This limits applicability of pattern matching.
>
> In addition, `JavaType` defines a bunch of predicates:
>
> * `isClass()`
> * `isArray()`
> * `isPrimitive()`
>
> This set of predicates is now incomplete, as it doesn't support all the possible leaves in the type hierarchy.
>
> Overall, it would be much better to just lean into pattern matching more, and drop the predicates.
For `TypeVarRef` should we collapse the methods `methodOwner` and `classOwner` to `owner()`, or in addition to, and document one should pattern match on the resulting object.
-------------
PR Review: https://git.openjdk.org/babylon/pull/64#pullrequestreview-2025752603
More information about the babylon-dev
mailing list