[dart2js] Fix extension methods in record_use

Apply a workaround for dropping the receiver. This makes the behavior
consistent with the VM.
Closes: https://github.com/dart-lang/native/issues/2926

We should find a better solution for extension methods that also
records the name of the extension and the type its on and the original
method name. This will be addressed later.
Bug: https://github.com/dart-lang/native/issues/2948

Change-Id: Iaa1f6afb82e4a70ed7af8e8ae4bbf92c4776637e
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-linux-chrome-try,dart2js-unit-linux-x64-release-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472540
Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Daco Harkes
2026-01-14 00:34:03 -08:00
committed by Commit Queue
parent 8f2f35cfc8
commit 29c8c6bbf3
2 changed files with 11 additions and 5 deletions
+11 -2
View File
@@ -5,6 +5,8 @@
import 'dart:collection' show Queue;
import 'dart:io';
// ignore: implementation_imports
import 'package:front_end/src/api_prototype/lowering_predicates.dart';
// ignore: implementation_imports
import 'package:front_end/src/api_unstable/dart2js.dart'
show Link, relativizeUri;
@@ -2407,14 +2409,21 @@ class SsaCodeGenerator implements HVisitor<void>, HBlockInformationVisitor {
record_use.Location? location = _recordUseLocation(sourceInformation);
final name = element.name!;
// TODO(https://github.com/dart-lang/native/issues/2948): Record the name of
// the extension instead of the desugared name.
final isExtensionMethod = hasUnnamedExtensionNamePrefix(name);
return RecordedCallWithArguments(
identifier: RecordedIdentifier(
name: element.name!,
name: name,
parent: element.enclosingClass?.name,
uri: relativizeUri(Uri.base, uri, Platform.isWindows),
),
location: location,
positionalArguments: arguments.map(_findConstant).toList(),
positionalArguments: arguments
.skip(isExtensionMethod ? 1 : 0)
.map(_findConstant)
.toList(),
);
}
@@ -142,7 +142,4 @@ const dart2jsNotSupported = {
'named_both.dart',
'named_optional.dart',
'named_required.dart',
// Extension methods are broken.
// https://github.com/dart-lang/native/issues/2926
'extension.dart',
};