Skip to content

Commit d3365fd

Browse files
t3dotggclaude
andcommitted
test(mobile): require the feed derivation on the cache-miss branch
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bea4a91 commit d3365fd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎apps/mobile/src/reactCompilerCoverage.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function walkAst(
123123
for (const child of Object.values(value)) walkAst(child, visit, childAncestors);
124124
}
125125

126-
// For each call to `callee`, whether it runs inside an `if ($[n] !== dep)`
127-
// cache block rather than on every render.
126+
// For each call to `callee`, whether it runs only on the cache-miss branch of
127+
// an `if ($[n] !== dep)` block rather than on every render.
128128
function compilerCachedCalls(file: string, callee: string): boolean[] {
129129
const result = compileLikeMetro(file, [], { ast: true });
130130
const cached: boolean[] = [];
@@ -134,8 +134,10 @@ function compilerCachedCalls(file: string, callee: string): boolean[] {
134134
if (node.callee.type !== "Identifier" || node.callee.name !== callee) return;
135135
cached.push(
136136
ancestors.some(
137-
(ancestor) =>
138-
ancestor.type === "IfStatement" && JSON.stringify(ancestor.test).includes('"name":"$"'),
137+
(ancestor, index) =>
138+
ancestor.type === "IfStatement" &&
139+
ancestors[index + 1] === ancestor.consequent &&
140+
JSON.stringify(ancestor.test).includes('"name":"$"'),
139141
),
140142
);
141143
});

0 commit comments

Comments
 (0)