Preserve Class<T> type arguments#1763
Closed
RushikeshGandhmal wants to merge 1 commit into
Closed
Conversation
Previously, `Class<T>` was explicitly erased to `Class` during type resolution, so type checks like `C is Class<A>` could not distinguish between `A` and `B`. Replace the erasure with a dedicated `ClassValueTypeNode` that keeps the type argument and validates it at runtime. Class values now pass type checks only when their represented class is a subclass of the type argument. Also reject invalid `Class<T>` arguments such as unions, nullables, constrained types, parameterized types, and modules with a clear error message. Fixes apple#1729.
RushikeshGandhmal
force-pushed
the
fix/1729-preserve-class-type-args
branch
from
July 12, 2026 13:42
0d3e01f to
a13c7f2
Compare
Author
|
Hi @bioball -- this is a more substantial type-system fix for #1729. I kept the change focused on Class resolution and used the existing ValidatingObjectSlotTypeNode pattern for validation. The regression test covers both the new semantics and the stdlib compatibility case. Thanks for taking a look! |
Contributor
|
This appears to be a duplicate of #1698. If you have input on this change, I would encourage you to discuss there so we can avoid splitting the discussion. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1729
Previously,
Class<T>was explicitly erased toClassduring type resolution, soC is Class<A>could not be distinguished fromC is Class<B>.This change introduces a
ClassValueTypeNodethat:Class<Type>used in stdlib generic signaturesA regression test is added covering:
C is Class<A>vsClass<B>)Class<T>arguments