Skip to content

Commit 4472e16

Browse files
committed
[compiler] Stop reusing ScopeDep type in AnalyzeFunctions
AnalyzeFunctions was reusing the `ReactiveScopeDependency` type since it happened to have a convenient shape, but we need to change this type to represent optionality. We now use a locally defined type instead. ghstack-source-id: e305c6e Pull Request resolved: facebook/react#30811
1 parent 7771d3a commit 4472e16

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler/packages/babel-plugin-react-compiler/src/Inference/AnalyseFunctions.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
IdentifierName,
1414
LoweredFunction,
1515
Place,
16-
ReactiveScopeDependency,
1716
isRefOrRefValue,
1817
makeInstructionId,
1918
} from '../HIR';
@@ -25,9 +24,14 @@ import {inferMutableContextVariables} from './InferMutableContextVariables';
2524
import {inferMutableRanges} from './InferMutableRanges';
2625
import inferReferenceEffects from './InferReferenceEffects';
2726

27+
type Dependency = {
28+
identifier: Identifier;
29+
path: Array<string>;
30+
};
31+
2832
// Helper class to track indirections such as LoadLocal and PropertyLoad.
2933
export class IdentifierState {
30-
properties: Map<Identifier, ReactiveScopeDependency> = new Map();
34+
properties: Map<Identifier, Dependency> = new Map();
3135

3236
resolve(identifier: Identifier): Identifier {
3337
const resolved = this.properties.get(identifier);
@@ -39,7 +43,7 @@ export class IdentifierState {
3943

4044
declareProperty(lvalue: Place, object: Place, property: string): void {
4145
const objectDependency = this.properties.get(object.identifier);
42-
let nextDependency: ReactiveScopeDependency;
46+
let nextDependency: Dependency;
4347
if (objectDependency === undefined) {
4448
nextDependency = {identifier: object.identifier, path: [property]};
4549
} else {
@@ -52,9 +56,7 @@ export class IdentifierState {
5256
}
5357

5458
declareTemporary(lvalue: Place, value: Place): void {
55-
const resolved: ReactiveScopeDependency = this.properties.get(
56-
value.identifier,
57-
) ?? {
59+
const resolved: Dependency = this.properties.get(value.identifier) ?? {
5860
identifier: value.identifier,
5961
path: [],
6062
};

0 commit comments

Comments
 (0)