Change code generation for dart2js to enable capturing

This CL changes the code generation for `dart2js` (and not for any other
backend) such that the variable holding the receiver of an anonymous
method invocation is declared as a normal local variable rather than
being a `Let` variable. This is needed because `dart2js` supports
capturing the former, but not the latter.

Change-Id: I054805f7006306186f2c6dfe36d7162b42293ae1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503420
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
This commit is contained in:
Erik Ernst
2026-05-21 04:22:30 -07:00
parent d18803c5be
commit 945978f5c0
117 changed files with 1802 additions and 265 deletions
+7
View File
@@ -447,6 +447,13 @@ abstract class Target {
/// Targets can opt in to using this node for general inlining.
bool get supportsFileUriExpression => false;
/// Whether this target supports capturing `Let` variables.
///
/// If the target does not support capturing `Let` variables then a `Let`
/// expression whose variable may be captured in a nested function literal
/// will be lowered to a block expression with a variable declaration.
bool get supportsLetVariableCapture => true;
/// Bit mask of [LateLowering] values for the late lowerings that should
/// be performed by the CFE.
///