Repository navigation
new of a generic class: specialize by the defaults only when nothing infers the type arguments - #694
Merged
Conversation
…infers the type arguments `new Set([1, 2])` made all of Set<any> (its default, `Set<V = any>`) beside the Set<si32> the constructor's arguments infer: the name was specialized by its defaults before the inference and the receiver were tried. Every model compiled the extra class; under -mm=own its methods failed (`any` elements), so every untyped Set failed to compile. Now, without type arguments but with constructor arguments or a receiver type, the name is resolved unspecialized, and the defaults apply only when neither gives the type arguments (`new Set()`). Test: test-generic-class-inference-no-default-specialization (no Pairs<any, any> in 00generic_class_constructor_inference). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
new Set([1, 2])made all ofSet<any>(its default,Set<V = any>) beside theSet<si32>the constructor's arguments infer:newspecialized the class name by its default type arguments before inference and the receiver were tried. Every model compiled the extra class; under-mm=ownits methods fail (anyelements), so every untypedSetfailed to compile.Now, without type arguments but with constructor arguments or a receiver type, the name is resolved unspecialized, and the defaults apply only when neither gives the type arguments. Unchanged:
new Box()is stillBox<any>,const c: Box<string> = new Box()is stillBox<string>, explicit type arguments as written.Tests
test-generic-class-inference-no-default-specialization(IR check on00generic_class_constructor_inference: noPairs<any, any>besidePairs<string, si32>).set_*tests now pass; themap_*ones still failing use an untypednew Map()with mixed keys, genuinelyMap<any, any>).Also updates the
-mm=ownguide's limits and the own containers spec note.🤖 Generated with Claude Code