Extend test coverage for object-literal/interface casts and method dispatch#259
Merged
Merged
Conversation
…spatch Adds four new test cases exercising variations not covered by the recent interface-vtable-cast arc (#256-258), which only ever tested zero-argument, single-method interfaces: - 00object_annotated_method_params.ts: type-literal-annotated object methods with PARAMETERS (that arc's fix only had zero-arg method coverage), including a same-module chained sibling-method call. - 00interface_object_array.ts: several distinct object literals (each its own per-type constant vtable) collected into a single interface-typed array and dispatched through the same call site in a loop - would catch a shared/aliased vtable or wrong-`this` bug that a single-object test can't. - export/import_object_literal_structural_typed_params.ts: extends export/import_object_literal_structural_typed.ts's cross-module coverage along the "zero-arg -> parameterized method" axis. Along the way, found and documented (not fixed) two new, real gaps in docs/interface-vtable-simplification-design.md: - a cross-module cast to a MULTI-method interface breaks for every vtable slot past 0 (wrong value at slot 1, crash at slot 2+) - every prior test in this arc only used single-method interfaces, so this was never exercised before. The committed cross-module test deliberately stays single-method to avoid committing a failing case. - (same-module only, unrelated) a value-returning method can't `return this.siblingMethod(...)` within the same type-literal-annotated object literal - calling the sibling as a bare statement works fine. Avoided in the committed tests. Full ctest suite: 730/730 passed (722 + 8 new). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…in typescript.cmake
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
Extends test coverage in areas the recent interface-vtable-cast arc (#256-258) never exercised — that arc's tests only ever used zero-argument, single-method interfaces.
00object_annotated_method_params.ts— type-literal-annotated object methods with parameters (the arc's fix, Give type-literal method members an implicit this param so annotated objects keep their receiver #258, only had zero-arg coverage), including a same-module chained sibling-method call (addTwicecallingthis.add(n)).00interface_object_array.ts— several distinct object literals (each its own per-type constant vtable) collected into a single interface-typed array and dispatched through the same call site in a loop — catches a shared/aliased-vtable or wrong-thisbug that a single-object test can't.export/import_object_literal_structural_typed_params.ts— extendsexport/import_object_literal_structural_typed.ts(Preserve source field order in the interface-cast object clone #257) along the "zero-arg → parameterized method" axis, cross-module.Bugs found (documented, not fixed — flagged for follow-up)
Two new, real gaps surfaced while writing these tests, both written up in
docs/interface-vtable-simplification-design.md:return this.siblingMethod(...)within the same type-literal-annotated object literal (fails to resolve the sibling's type) — calling it as a bare statement works fine. Avoided in the committed tests.Neither blocks this PR's tests, which are scoped to stay within currently-working behavior.
Test plan
Full ctest suite: 730/730 passed (722 existing + 8 new).
🤖 Generated with Claude Code