Skip to content

Commit 7eb4ebd

Browse files
committed
[compiler] More fbt compatibility (#34887)
In my previous PR I fixed some cases but broke others. So, new approach. Two phase algorithm: * First pass is forward data flow to determine all usages of macros. This is necessary because many of Meta's macros have variants that can be accessed via properties, eg you can do `macro(...)` but also `macro.variant(...)`. * Second pass is backwards data flow to find macro invocations (JSX and calls) and then merge their operands into the same scope as the macro call. Note that this required updating PromoteUsedTemporaries to avoid promoting macro calls that have interposing instructions between their creation and usage. Macro calls in general are pure so it should be safe to reorder them. In addition, we're now more precise about `<fb:plural>`, `<fbt:param>`, `fbt.plural()` and `fbt.param()`, which don't actually require all their arguments to be inlined. The whole point is that the plural/param value is an arbitrary value (along with a string name). So we no longer transitively inline the arguments, we just make sure that they don't get inadvertently promoted to named variables. One caveat: we actually don't do anything to treat macro functions as non-mutating, so `fbt.plural()` and friends (function form) may still sometimes group arguments just due to mutability inference. In a follow-up, i'll work to infer the types of nested macro functions as non-mutating. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34887). * #34900 * __->__ #34887 DiffTrain build for [adbc32d](adbc32d)
1 parent b4ccbcd commit 7eb4ebd

26 files changed

+415
-399
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.3.0-native-fb-1324e1bb-20251016
1+
19.3.0-native-fb-adbc32de-20251017

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<23fea785d071f231160101af91652346>>
10+
* @generated SignedSource<<d45b6981d33fdc6982c2e7f11324ea89>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
407+
exports.version = "19.3.0-native-fb-adbc32de-20251017";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<05762bf0b196ccf10425e080e0ef809b>>
10+
* @generated SignedSource<<a9c0187114d968570a503802fc377bcc>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
206+
exports.version = "19.3.0-native-fb-adbc32de-20251017";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<05762bf0b196ccf10425e080e0ef809b>>
10+
* @generated SignedSource<<a9c0187114d968570a503802fc377bcc>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
206+
exports.version = "19.3.0-native-fb-adbc32de-20251017";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<0907d546d373fabf1a1fe17586915adc>>
10+
* @generated SignedSource<<528131a70060780764c1d0597fe0db1c>>
1111
*/
1212

1313
/*
@@ -30117,11 +30117,11 @@ __DEV__ &&
3011730117
};
3011830118
(function () {
3011930119
var isomorphicReactPackageVersion = React.version;
30120-
if ("19.3.0-native-fb-1324e1bb-20251016" !== isomorphicReactPackageVersion)
30120+
if ("19.3.0-native-fb-adbc32de-20251017" !== isomorphicReactPackageVersion)
3012130121
throw Error(
3012230122
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3012330123
(isomorphicReactPackageVersion +
30124-
"\n - react-dom: 19.3.0-native-fb-1324e1bb-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
30124+
"\n - react-dom: 19.3.0-native-fb-adbc32de-20251017\nLearn more: https://react.dev/warnings/version-mismatch")
3012530125
);
3012630126
})();
3012730127
("function" === typeof Map &&
@@ -30158,10 +30158,10 @@ __DEV__ &&
3015830158
!(function () {
3015930159
var internals = {
3016030160
bundleType: 1,
30161-
version: "19.3.0-native-fb-1324e1bb-20251016",
30161+
version: "19.3.0-native-fb-adbc32de-20251017",
3016230162
rendererPackageName: "react-dom",
3016330163
currentDispatcherRef: ReactSharedInternals,
30164-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016"
30164+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017"
3016530165
};
3016630166
internals.overrideHookState = overrideHookState;
3016730167
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30311,5 +30311,5 @@ __DEV__ &&
3031130311
listenToAllSupportedEvents(container);
3031230312
return new ReactDOMHydrationRoot(initialChildren);
3031330313
};
30314-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
30314+
exports.version = "19.3.0-native-fb-adbc32de-20251017";
3031530315
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<43facab9aa21845afe2207c783f5d9c1>>
10+
* @generated SignedSource<<9599abaec3ed1c8ebd5c62403c034a20>>
1111
*/
1212

1313
/*
@@ -17581,14 +17581,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1758117581
};
1758217582
var isomorphicReactPackageVersion$jscomp$inline_2060 = React.version;
1758317583
if (
17584-
"19.3.0-native-fb-1324e1bb-20251016" !==
17584+
"19.3.0-native-fb-adbc32de-20251017" !==
1758517585
isomorphicReactPackageVersion$jscomp$inline_2060
1758617586
)
1758717587
throw Error(
1758817588
formatProdErrorMessage(
1758917589
527,
1759017590
isomorphicReactPackageVersion$jscomp$inline_2060,
17591-
"19.3.0-native-fb-1324e1bb-20251016"
17591+
"19.3.0-native-fb-adbc32de-20251017"
1759217592
)
1759317593
);
1759417594
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17610,10 +17610,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1761017610
};
1761117611
var internals$jscomp$inline_2637 = {
1761217612
bundleType: 0,
17613-
version: "19.3.0-native-fb-1324e1bb-20251016",
17613+
version: "19.3.0-native-fb-adbc32de-20251017",
1761417614
rendererPackageName: "react-dom",
1761517615
currentDispatcherRef: ReactSharedInternals,
17616-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016"
17616+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017"
1761717617
};
1761817618
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1761917619
var hook$jscomp$inline_2638 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17720,4 +17720,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1772017720
listenToAllSupportedEvents(container);
1772117721
return new ReactDOMHydrationRoot(initialChildren);
1772217722
};
17723-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
17723+
exports.version = "19.3.0-native-fb-adbc32de-20251017";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d7fa2da797d8662766fa021f2ff49295>>
10+
* @generated SignedSource<<b3c039e7447b79df8814dfcb601b3d57>>
1111
*/
1212

1313
/*
@@ -19703,14 +19703,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1970319703
};
1970419704
var isomorphicReactPackageVersion$jscomp$inline_2375 = React.version;
1970519705
if (
19706-
"19.3.0-native-fb-1324e1bb-20251016" !==
19706+
"19.3.0-native-fb-adbc32de-20251017" !==
1970719707
isomorphicReactPackageVersion$jscomp$inline_2375
1970819708
)
1970919709
throw Error(
1971019710
formatProdErrorMessage(
1971119711
527,
1971219712
isomorphicReactPackageVersion$jscomp$inline_2375,
19713-
"19.3.0-native-fb-1324e1bb-20251016"
19713+
"19.3.0-native-fb-adbc32de-20251017"
1971419714
)
1971519715
);
1971619716
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19732,10 +19732,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1973219732
};
1973319733
var internals$jscomp$inline_2382 = {
1973419734
bundleType: 0,
19735-
version: "19.3.0-native-fb-1324e1bb-20251016",
19735+
version: "19.3.0-native-fb-adbc32de-20251017",
1973619736
rendererPackageName: "react-dom",
1973719737
currentDispatcherRef: ReactSharedInternals,
19738-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016",
19738+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017",
1973919739
getLaneLabelMap: function () {
1974019740
for (
1974119741
var map = new Map(), lane = 1, index$332 = 0;
@@ -19858,4 +19858,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1985819858
listenToAllSupportedEvents(container);
1985919859
return new ReactDOMHydrationRoot(initialChildren);
1986019860
};
19861-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
19861+
exports.version = "19.3.0-native-fb-adbc32de-20251017";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<f5bd51d677a94f034fe69f9fb4f5839d>>
10+
* @generated SignedSource<<e70aafbe9891daadb21c7d749d8ae470>>
1111
*/
1212

1313
/*
@@ -30173,11 +30173,11 @@ __DEV__ &&
3017330173
};
3017430174
(function () {
3017530175
var isomorphicReactPackageVersion = React.version;
30176-
if ("19.3.0-native-fb-1324e1bb-20251016" !== isomorphicReactPackageVersion)
30176+
if ("19.3.0-native-fb-adbc32de-20251017" !== isomorphicReactPackageVersion)
3017730177
throw Error(
3017830178
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
3017930179
(isomorphicReactPackageVersion +
30180-
"\n - react-dom: 19.3.0-native-fb-1324e1bb-20251016\nLearn more: https://react.dev/warnings/version-mismatch")
30180+
"\n - react-dom: 19.3.0-native-fb-adbc32de-20251017\nLearn more: https://react.dev/warnings/version-mismatch")
3018130181
);
3018230182
})();
3018330183
("function" === typeof Map &&
@@ -30214,10 +30214,10 @@ __DEV__ &&
3021430214
!(function () {
3021530215
var internals = {
3021630216
bundleType: 1,
30217-
version: "19.3.0-native-fb-1324e1bb-20251016",
30217+
version: "19.3.0-native-fb-adbc32de-20251017",
3021830218
rendererPackageName: "react-dom",
3021930219
currentDispatcherRef: ReactSharedInternals,
30220-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016"
30220+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017"
3022130221
};
3022230222
internals.overrideHookState = overrideHookState;
3022330223
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -30683,7 +30683,7 @@ __DEV__ &&
3068330683
exports.useFormStatus = function () {
3068430684
return resolveDispatcher().useHostTransitionStatus();
3068530685
};
30686-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
30686+
exports.version = "19.3.0-native-fb-adbc32de-20251017";
3068730687
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
3068830688
"function" ===
3068930689
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a1e51f399b697eb7bb61ac423180d8b3>>
10+
* @generated SignedSource<<46342e8df09ab8ab078238d27c137d74>>
1111
*/
1212

1313
/*
@@ -17592,14 +17592,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1759217592
};
1759317593
var isomorphicReactPackageVersion$jscomp$inline_2061 = React.version;
1759417594
if (
17595-
"19.3.0-native-fb-1324e1bb-20251016" !==
17595+
"19.3.0-native-fb-adbc32de-20251017" !==
1759617596
isomorphicReactPackageVersion$jscomp$inline_2061
1759717597
)
1759817598
throw Error(
1759917599
formatProdErrorMessage(
1760017600
527,
1760117601
isomorphicReactPackageVersion$jscomp$inline_2061,
17602-
"19.3.0-native-fb-1324e1bb-20251016"
17602+
"19.3.0-native-fb-adbc32de-20251017"
1760317603
)
1760417604
);
1760517605
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17621,10 +17621,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1762117621
};
1762217622
var internals$jscomp$inline_2640 = {
1762317623
bundleType: 0,
17624-
version: "19.3.0-native-fb-1324e1bb-20251016",
17624+
version: "19.3.0-native-fb-adbc32de-20251017",
1762517625
rendererPackageName: "react-dom",
1762617626
currentDispatcherRef: ReactSharedInternals,
17627-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016"
17627+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017"
1762817628
};
1762917629
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1763017630
var hook$jscomp$inline_2641 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17884,4 +17884,4 @@ exports.useFormState = function (action, initialState, permalink) {
1788417884
exports.useFormStatus = function () {
1788517885
return ReactSharedInternals.H.useHostTransitionStatus();
1788617886
};
17887-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
17887+
exports.version = "19.3.0-native-fb-adbc32de-20251017";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b383e6ea28be68a6c2016f3f9e599fa5>>
10+
* @generated SignedSource<<848fb428cb39b3a4580876534757156f>>
1111
*/
1212

1313
/*
@@ -19718,14 +19718,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1971819718
};
1971919719
var isomorphicReactPackageVersion$jscomp$inline_2376 = React.version;
1972019720
if (
19721-
"19.3.0-native-fb-1324e1bb-20251016" !==
19721+
"19.3.0-native-fb-adbc32de-20251017" !==
1972219722
isomorphicReactPackageVersion$jscomp$inline_2376
1972319723
)
1972419724
throw Error(
1972519725
formatProdErrorMessage(
1972619726
527,
1972719727
isomorphicReactPackageVersion$jscomp$inline_2376,
19728-
"19.3.0-native-fb-1324e1bb-20251016"
19728+
"19.3.0-native-fb-adbc32de-20251017"
1972919729
)
1973019730
);
1973119731
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -19747,10 +19747,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1974719747
};
1974819748
var internals$jscomp$inline_2383 = {
1974919749
bundleType: 0,
19750-
version: "19.3.0-native-fb-1324e1bb-20251016",
19750+
version: "19.3.0-native-fb-adbc32de-20251017",
1975119751
rendererPackageName: "react-dom",
1975219752
currentDispatcherRef: ReactSharedInternals,
19753-
reconcilerVersion: "19.3.0-native-fb-1324e1bb-20251016",
19753+
reconcilerVersion: "19.3.0-native-fb-adbc32de-20251017",
1975419754
getLaneLabelMap: function () {
1975519755
for (
1975619756
var map = new Map(), lane = 1, index$332 = 0;
@@ -20026,7 +20026,7 @@ exports.useFormState = function (action, initialState, permalink) {
2002620026
exports.useFormStatus = function () {
2002720027
return ReactSharedInternals.H.useHostTransitionStatus();
2002820028
};
20029-
exports.version = "19.3.0-native-fb-1324e1bb-20251016";
20029+
exports.version = "19.3.0-native-fb-adbc32de-20251017";
2003020030
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2003120031
"function" ===
2003220032
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)