You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
instanceof a Map/Set SUBCLASS is false (m instanceof MyMap); only the native base edge survives #7575
m instanceof MyMap is false for a class MyMap extends Map instance. m instanceof Map is correct. Found while fixing #7570 (PR #7573); it is a different bug and survives that fix — it reproduces with and without the
base-type annotation, so it is not a declared-type-lowering problem.
Repro
classMyMap<K,V>extendsMap<K,V>{}classPlain{}classSubPlainextendsPlain{}consta=newMyMap<string,number>();console.log("unannotated:",ainstanceofMyMap,ainstanceofMap);constb: Map<string,number>=newMyMap<string,number>();console.log("annotated:",binstanceofMyMap,binstanceofMap);// control: an ordinary class hierarchy is fineconstc: Plain=newSubPlain();console.log("plain annotated:",cinstanceofSubPlain,cinstanceofPlain);
So the intermediate/leaf class edge is what is lost, not the base edge: the
chain walk finds Map but not MyMap. The same holds for class MySet extends Set.
Notes for whoever picks this up
Ordinary (non-native-base) inheritance is unaffected, so this is specific to
the super()-to-a-native-base wiring, not to instanceof in general.
CLAUDE.md's Known-weak areas entry on native base-class subclassing is the
right place to start: "a native base's surface is installed at super() time
and its parent edge lives in the class registry".
The existing test_gap_6325_map_set_subclass.ts only asserts m instanceof Map, which is why this was never caught.
test_gap_7570_map_set_declared_base_type.ts deliberately asserts only instanceof Map / instanceof Set, with an inline comment pointing here.
Whoever fixes this should tighten those two lines to also assert instanceof MyMap / instanceof MySet.
Activity
docs(changelog): #7575 changeset fragment for PR #7631
fix(instanceof): #7575 — a monomorphized generic class is an instance…
fix(instanceof): #7575 follow-up — cover generic non-Map bases, Array…
docs(changelog): #7575 changeset fragment for PR #7631
fix(codegen): thread specialized_from through #7627's new Class fixture
fix(instanceof): #7575 — a monomorphized generic class is an instance…
fix(instanceof): #7575 follow-up — cover generic non-Map bases, Array…
docs(changelog): #7575 changeset fragment for PR #7631
fix(codegen): thread specialized_from through #7627's new Class fixture
fix(instanceof): a monomorphized generic class is an instance of its …
fix(runtime): a generic specialization answers with its generic's con…