Fix generic constraint matching for method-shaped receivers#273
Merged
ASDAlexander77 merged 1 commit intoJul 21, 2026
Merged
Conversation
…am misalignment)
extendsTypeFuncTypes skipped the receiver's bound `this` param when
comparing against a method-shaped constraint (e.g. `T extends { next(): ... }`),
but never skipped the constraint's own leading `this` placeholder (OpaqueType)
in lockstep. That misaligned the two param lists by one, so every extension
method whose generic constraint required a method field (e.g. DefaultLib's
__Iterator.take/drop/every/filter/find/forEach/map/reduce/some/toArray on
generator return types) failed to resolve.
Also add ObjectType/ObjectStorageType cases to getFieldTypeByFieldName so
boxed generator return types expose their fields to structural constraint
checks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ASDAlexander77
deleted the
fix/iterator-helper-extension-constraint-mismatch
branch
July 21, 2026 17:47
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.
Summary
extendsTypeFuncTypesskipped the receiver's boundthisparam when comparing against a method-shaped generic constraint (e.g.TIter extends { next(): {...} }), but never skipped the constraint's own leadingthisplaceholder (OpaqueType) in lockstep — misaligning the two parameter lists by one and causing every subsequent parameter comparison to fail (collapsing to<<NULL TYPE>>vs!ts.opaque).__Iterator.take/drop/every/filter/find/forEach/map/reduce/some/toArraynever resolved on generator (function*) return types (fibonacci().take(5),fibonacci().every(fn), etc. all failed to compile).ObjectType/ObjectStorageTypecases togetFieldTypeByFieldNameso a boxed generator return type exposes its fields (e.g.next()) to structural constraint checks in the first place.Root-caused via LLVM debug tracing (
-debug-only=mlir) on a Debug JIT build, isolating the exactextendsTyperecursion where the receiver'snext()method type was compared against the constraint'snext()signature and one side's parameter came back null.Test plan
tslang(Debug + Release) with the fixtests.ps1suite (release/debug × compile/jit, 150 tests × 4 = 600 runs): 150/150 passing on all four, including the 10 previously-failingiterator_*.tstests (iterator_drop/every/filter/find/forEach/map/reduce/some/take/toArray)🤖 Generated with Claude Code