[hir] Refactor checkValidDependencyId to accept a dep
Sathya Gunasekaran committed
May 30, 2023 at 13:44 UTC
1d536af4f74b1a4ca7385e1caff091d4423d70ab
2 files changed
+6
-5
compiler/forget/src/ReactiveScopes/DeriveMinimalDependencies.ts
+2
-2
@@ -143,10 +143,10 @@ export class ReactiveScopeDependencyTree {
143
addDepsFromInnerScope(
144
depsFromInnerScope: ReactiveScopeDependencyTree,
145
innerScopeInConditionalWithinParent: boolean,
146
- checkValidDepIdFn: (id: Identifier) => boolean
146
+ checkValidDepIdFn: (dep: ReactiveScopeDependency) => boolean
147
): void {
148
for (const [id, otherRoot] of depsFromInnerScope.#roots) {
149
- if (!checkValidDepIdFn(id)) {
149
+ if (!checkValidDepIdFn({ identifier: id, path: [] })) {
150
continue;
151
}
152
let currRoot = this.#getOrCreateRoot(id);
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+4
-3
@@ -184,7 +184,7 @@ class Context {
184
this.#dependencies.addDepsFromInnerScope(
185
scopedDependencies,
186
this.#inConditionalWithinScope,
187
- this.#checkValidDependencyId.bind(this)
187
+ this.#checkValidDependency.bind(this)
188
);
189
return minInnerScopeDependencies;
190
}
@@ -313,7 +313,8 @@ class Context {
313
}
314
315
// Checks if identifier is a valid dependency in the current scope
316
- #checkValidDependencyId(identifier: Identifier): boolean {
316
+ #checkValidDependency(maybeDependency: ReactiveScopeDependency): boolean {
317
+ const identifier = maybeDependency.identifier;
318
// If this operand is used in a scope, has a dynamic value, and was defined
319
// before this scope, then its a dependency of the scope.
320
const currentDeclaration =
@@ -390,7 +391,7 @@ class Context {
391
});
392
}
393
393
- if (this.#checkValidDependencyId(maybeDependency.identifier)) {
394
+ if (this.#checkValidDependency(maybeDependency)) {
395
this.#depsInCurrentConditional.add(maybeDependency, true);
396
// Add info about this dependency to the existing tree
397
// We do not try to join/reduce dependencies here due to missing info