mirror of
https://github.com/morluto/rea.git
synced 2026-11-04 22:06:10 +00:00
fix(native): preserve unknown Swift extension contexts
This commit is contained in:
1 parent
25b28ffe8b
commit
84f4eb42e1
2 files changed
+32
-1
No files matched your search
@@ -42,7 +42,14 @@ export const classifySwiftSymbol = (
|
||||
// A zero-prefixed identifier uses word substitutions or Punycode. We
|
||||
// cannot tell whether it continues a nested type or names a member, so
|
||||
// retaining the outer category would be a guess.
|
||||
if (mangling.charAt(offset) === "0") category = null;
|
||||
if (
|
||||
mangling.charAt(offset) === "0" ||
|
||||
// A substituted module can introduce a constrained extension after
|
||||
// the nominal type. This parser does not decode that context, so it
|
||||
// cannot retain the preceding nominal category as the member's owner.
|
||||
mangling.startsWith("AA", offset)
|
||||
)
|
||||
category = null;
|
||||
break;
|
||||
}
|
||||
const kind = mangling.charAt(end);
|
||||
|
||||
@@ -25,6 +25,30 @@ describe("modern Swift category evidence", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps undecoded substituted extension contexts unclassified", () => {
|
||||
const names = [
|
||||
"_$s1M7WrapperVAASQRzlE4sameySbxF",
|
||||
"_$s1M3BoxVAARi_zrlE1vxvM",
|
||||
];
|
||||
const result = categorizeSwiftTypes(
|
||||
names.map((name, index) => ({ address: String(index), name })),
|
||||
);
|
||||
expect(result.categories.structs.count).toBe(0);
|
||||
expect(result.categories.other.count).toBe(2);
|
||||
expect(result.unclassified.map(({ name }) => name)).toEqual(names);
|
||||
const controls = [
|
||||
["_$s1M7WrapperV1vxvg", "structs"],
|
||||
["_$s1M7WrapperVMa", "structs"],
|
||||
["_$s1M7WrapperVACyxGxcfC", "structs"],
|
||||
["_$s10Foundation4DataV1ME10countTwiceSiyF", "extensions"],
|
||||
] as const;
|
||||
for (const [name, category] of controls)
|
||||
expect(
|
||||
categorizeSwiftTypes([{ address: "0x1", name }]).categories[category]
|
||||
.count,
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
it("retains unresolved Swift observations under category filters", () => {
|
||||
const names = [
|
||||
"$s4main13swiftIndirectySiAA7Scoring_p_SitF",
|
||||
|
||||
Reference in new issue
Block a user