Skip to content

Use a type refiner#1

Merged
kyay10 merged 8 commits into
masterfrom
type-refiner
Jan 14, 2026
Merged

Use a type refiner#1
kyay10 merged 8 commits into
masterfrom
type-refiner

Conversation

@kyay10
Copy link
Copy Markdown
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
Copy Markdown
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.

@kyay10
Copy link
Copy Markdown
Owner Author

kyay10 commented Jan 14, 2026

Since this branch has become my main focus, and given how well it works, I'm merging it. We can always go back to the original approach if necessary. This is ultimately less hacky

@kyay10 kyay10 merged commit 7f0f481 into master Jan 14, 2026
2 checks passed
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.

1 participant