[compiler] Clean up deadcode: ReactiveFunctionValue (#32098)
(title) --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32098). * #32287 * #32104 * __->__ #32098 * #32097
mofeiZ committed
Feb 18, 2025 at 09:37 UTC
498514c04d824f88a9b77595c18c1323f4d1006f
6 files changed
+1
-56
compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
+1
-10
@@ -108,16 +108,7 @@ export type ReactiveValue =
108
| ReactiveLogicalValue
109
| ReactiveSequenceValue
110
| ReactiveTernaryValue
111
- | ReactiveOptionalCallValue
112
- | ReactiveFunctionValue;
113
-
114
-export type ReactiveFunctionValue = {
115
- kind: 'ReactiveFunctionValue';
116
- fn: ReactiveFunction;
117
- dependencies: Array<Place>;
118
- returnType: t.FlowType | t.TSType | null;
119
- loc: SourceLocation;
120
-};
111
+ | ReactiveOptionalCallValue;
112
113
export type ReactiveLogicalValue = {
114
kind: 'LogicalExpression';
compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
-5
@@ -6,7 +6,6 @@
6
*/
7
8
import generate from '@babel/generator';
9
-import {printReactiveFunction} from '..';
9
import {CompilerError} from '../CompilerError';
10
import {printReactiveScopeSummary} from '../ReactiveScopes/PrintReactiveFunction';
11
import DisjointSet from '../Utils/DisjointSet';
@@ -701,10 +700,6 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
700
value = `FinishMemoize decl=${printPlace(instrValue.decl)}`;
701
break;
702
}
704
- case 'ReactiveFunctionValue': {
705
- value = `FunctionValue ${printReactiveFunction(instrValue.fn)}`;
706
- break;
707
- }
703
default: {
704
assertExhaustive(
705
instrValue,
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts
-1
@@ -2231,7 +2231,6 @@ function codegenInstructionValue(
2231
);
2232
break;
2233
}
2234
- case 'ReactiveFunctionValue':
2234
case 'StartMemoize':
2235
case 'FinishMemoize':
2236
case 'Debugger':
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts
-8
@@ -772,14 +772,6 @@ function computeMemoizationInputs(
772
rvalues: operands,
773
};
774
}
775
- case 'ReactiveFunctionValue': {
776
- CompilerError.invariant(false, {
777
- reason: `Unexpected ReactiveFunctionValue node`,
778
- description: null,
779
- loc: value.loc,
780
- suggestions: null,
781
- });
782
- }
775
case 'UnsupportedNode': {
776
CompilerError.invariant(false, {
777
reason: `Unexpected unsupported node`,
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/visitors.ts
-25
@@ -73,15 +73,6 @@ export class ReactiveFunctionVisitor<TState = void> {
73
this.visitValue(value.id, value.value, state);
74
break;
75
}
76
- case 'ReactiveFunctionValue': {
77
- this.visitReactiveFunctionValue(
78
- id,
79
- value.dependencies,
80
- value.fn,
81
- state,
82
- );
83
- break;
84
- }
76
default: {
77
for (const place of eachInstructionValueOperand(value)) {
78
this.visitPlace(id, place, state);
@@ -434,18 +425,6 @@ export class ReactiveFunctionTransform<
425
}
426
break;
427
}
437
- case 'ReactiveFunctionValue': {
438
- const nextValue = this.transformReactiveFunctionValue(
439
- id,
440
- value.dependencies,
441
- value.fn,
442
- state,
443
- );
444
- if (nextValue.kind === 'replace') {
445
- value.fn = nextValue.value;
446
- }
447
- break;
448
- }
428
default: {
429
for (const place of eachInstructionValueOperand(value)) {
430
this.visitPlace(id, place, state);
@@ -619,10 +598,6 @@ export function* eachReactiveValueOperand(
598
yield* eachReactiveValueOperand(instrValue.alternate);
599
break;
600
}
622
- case 'ReactiveFunctionValue': {
623
- yield* instrValue.dependencies;
624
- break;
625
- }
601
default: {
602
yield* eachInstructionValueOperand(instrValue);
603
}
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidatePreservedManualMemoization.ts
-7
@@ -327,13 +327,6 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
327
case 'OptionalExpression': {
328
return this.recordDepsInValue(value.value, state);
329
}
330
- case 'ReactiveFunctionValue': {
331
- CompilerError.throwTodo({
332
- reason:
333
- 'Handle ReactiveFunctionValue in ValidatePreserveManualMemoization',
334
- loc: value.loc,
335
- });
336
- }
330
case 'ConditionalExpression': {
331
this.recordDepsInValue(value.test, state);
332
this.recordDepsInValue(value.consequent, state);