diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts index 2baf709eb0..4a48376c25 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/MergeReactiveScopesThatInvalidateTogether.ts @@ -110,15 +110,15 @@ class Transform extends ReactiveFunctionTransform { - this.visitScope(scope, scope.scope.dependencies); + this.visitScope(scopeBlock, scopeBlock.scope.dependencies); if ( state !== null && - areEqualDependencies(state, scope.scope.dependencies) + areEqualDependencies(state, scopeBlock.scope.dependencies) ) { - return { kind: "replace-many", value: scope.instructions }; + return { kind: "replace-many", value: scopeBlock.instructions }; } else { return { kind: "keep" }; } @@ -133,7 +133,7 @@ class Transform extends ReactiveFunctionTransform; @@ -160,7 +160,7 @@ class Transform extends ReactiveFunctionTransform ({ + [...current.scope.declarations.values()].map((declaration) => ({ identifier: declaration.identifier, path: [], })) ), - b.scope.dependencies + next.scope.dependencies ) ) { log(` outputs of prev are input to current`); return true; } log(` cannot merge scopes:`); - log(` ${printReactiveScopeSummary(a.scope)}`); - log(` ${printReactiveScopeSummary(b.scope)}`); + log(` ${printReactiveScopeSummary(current.scope)}`); + log(` ${printReactiveScopeSummary(next.scope)}`); return false; } @@ -442,16 +450,16 @@ function areEqualPaths(a: Array, b: Array): boolean { * A special-case is if the scope has no dependencies, then its output will * *never* change and it's also eligible for merging. */ -function scopeIsEligibleForMerging(scope: ReactiveScopeBlock): boolean { - if (scope.scope.dependencies.size === 0) { +function scopeIsEligibleForMerging(scopeBlock: ReactiveScopeBlock): boolean { + if (scopeBlock.scope.dependencies.size === 0) { /* * Regardless of the type of value produced, if the scope has no dependencies * then its value will never change. */ return true; } - const visitor = new DeclarationTypeVisitor(scope.scope); - visitor.visitScope(scope, undefined); + const visitor = new DeclarationTypeVisitor(scopeBlock.scope); + visitor.visitScope(scopeBlock, undefined); return visitor.alwaysInvalidatesOnInputChange; } @@ -464,11 +472,11 @@ class DeclarationTypeVisitor extends ReactiveFunctionVisitor { this.scope = scope; } - override visitScope(scope: ReactiveScopeBlock, state: void): void { - if (scope.scope.id !== this.scope.id) { + override visitScope(scopeBlock: ReactiveScopeBlock, state: void): void { + if (scopeBlock.scope.id !== this.scope.id) { return; } - this.traverseScope(scope, state); + this.traverseScope(scopeBlock, state); } override visitInstruction(