[Repo Assist] [JS/TS] Fix super call in generic class hierarchy using wrong mangled name#4414
Open
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
…gled name (fix #3895) When calling `base.Method()` in a class that inherits through a chain of generic classes, the overload hash suffix was computed incorrectly. For example, if `ProjectSelection` inherits `SelectionAspect<'Container>` which inherits `AspectBase<'C>`, calling `base.Attach(owner)` from `ProjectSelection.Attach` would generate `super["...AspectBase.Attach1505"]` but the method was defined as `"...AspectBase.Attach2B595"`, causing a runtime error. Root cause: `callAttachedMember` was called with the correct base entity (`AspectBase<'C>`) but the override member from the intermediate class (`SelectionAspect<'Container>.Attach`). `getOverloadSuffixFrom` uses the entity's generic param names (`['C']`) as normalization keys, but the member's parameter types use the intermediate class's names (`'Container`), causing the lookup to fail and producing a different hash. Fix: after finding the base entity with `tryFindBaseEntity`, also find the corresponding dispatch slot member in that entity so the hash is computed with matching entity and member generic parameter names. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7 tasks
16 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes #3895 —
super.Method()calls in multi-level generic class hierarchies generate the wrong mangled name, causing a runtime error likesuper.OverrideIssue.AspectBase\1.Attach1505 is not a function`.Root Cause
When
callAttachedMembercomputes the mangled name for asupercall, it callsgetOverloadSuffixFrom(baseEntity, overrideMember). The hash is computed by mapping the base entity's generic parameter names (e.g.'C) to positional indices — but the override member's parameter types use the intermediate class's generic parameter names (e.g.'Container). The dict lookup fails, the type falls back to an empty constraint string, and produces a different hash than the one used at method definition time.Example:
AspectBase<'C>definesAttach('C)— hash computed asgenParams={"C"→"0"}, type"C"→"0"→ hash2B595ProjectSelection.Attachcallsbase.Attach(owner)— Fable findsAspectBaseas the base entity, but usesSelectionAspect<'Container>.Attachas the member.genParams={"C"→"0"}but type is"Container"→ not in dict → hash1505❌Fix
After finding the base entity with
tryFindBaseEntity, also calltryFindAbstractMemberto retrieve the dispatch slot from that entity and pass it tocallAttachedMember. This ensures bothentandmembshare the same generic parameter namespace, producing a consistent hash.Changed file:
src/Fable.Transforms/FSharp2Fable.Util.fs— targeted change in the super-call entity resolution block (~10 lines).Test Plan
tests/Js/Main/TypeTests.fsthat creates a 3-level generic class hierarchy and callsAttach("hello"), verifying the base method was invoked (would throw at runtime before this fix)🤖 Generated with Repo Assist