Skip to content

Conversation

@kyay10
Copy link
Owner

@kyay10 kyay10 commented Oct 20, 2025

This sadly requires reflection...
The reflection is used to create an instance of TypeComponents with a custom ConeInferenceContext, which is used to inject a type refiner that automatically applies K, and it also returns the canonical K representation as a supertype to every generic type.
It also tracks the original expanded version of every K type, and provides that as a supertype too when asked. That means that expandTo calls are largely unnecessary, and, in fact, are no longer special or intrinsic.
It's much nicer to use though, and uses less hacky compiler tricks.

@kyay10
Copy link
Owner Author

kyay10 commented Oct 21, 2025

This works incredibly well... I'm very tempted to just merge it. The usage of reflection is scary, but Unsafe.allocateInstance is well supported, and necessary for a lot of serialization frameworks. We could move to Objenesis to ensure futre compatibility.
I doubt that the compiler will ever expose a TypeComponents constructor that takes in a ConeInferenceContext.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants