diff --git a/pkg/compiler/test/record_use/record_use_test.dart b/pkg/compiler/test/record_use/record_use_test.dart index 4c2da019141..ed81a94f0aa 100644 --- a/pkg/compiler/test/record_use/record_use_test.dart +++ b/pkg/compiler/test/record_use/record_use_test.dart @@ -231,4 +231,4 @@ Future compileWithUsages({ .toString(); } -const Set dart2jsNotSupported = {}; +const Set dart2jsNotSupported = {'external_function.dart'}; diff --git a/pkg/vm/testcases/transformations/record_use/lib/external_function.dart b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart new file mode 100644 index 00000000000..1fc12a993db --- /dev/null +++ b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:meta/meta.dart' show RecordUse; + +void main() { + print(someExternalFunction(6)); + print(SomeClass.someExternalStaticMethod(7)); +} + +@RecordUse() +external int someExternalFunction(int k); + +class SomeClass { + @RecordUse() + external static int someExternalStaticMethod(int k); +} diff --git a/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.aot.expect b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.aot.expect new file mode 100644 index 00000000000..f13b980e390 --- /dev/null +++ b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.aot.expect @@ -0,0 +1,28 @@ +library #lib; +import self as self; +import "dart:core" as core; +import "package:meta/meta.dart" as meta; + +import "package:meta/meta.dart" show RecordUse; + +abstract class SomeClass extends core::Object { + + [@vm.inferred-return-type.metadata=int] + [@vm.unboxing-info.metadata=(i)->i] + @#C1 + external static method someExternalStaticMethod([@vm.inferred-arg-type.metadata=dart.core::_Smi (value: 7)] core::int k) → core::int; +} + +[@vm.inferred-return-type.metadata=dart.core::Null? (value: null)] +static method main() → void { + core::print([@vm.inferred-type.metadata=int] self::someExternalFunction(6)); + core::print([@vm.inferred-type.metadata=int] self::SomeClass::someExternalStaticMethod(7)); +} + +[@vm.inferred-return-type.metadata=int] +[@vm.unboxing-info.metadata=(i)->i] +@#C1 +external static method someExternalFunction([@vm.inferred-arg-type.metadata=dart.core::_Smi (value: 6)] core::int k) → core::int; +constants { + #C1 = meta::RecordUse {} +} diff --git a/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.json.expect b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.json.expect new file mode 100644 index 00000000000..6ae72176b4f --- /dev/null +++ b/pkg/vm/testcases/transformations/record_use/lib/external_function.dart.json.expect @@ -0,0 +1,83 @@ +{ + "constants": [ + { + "type": "int", + "value": 6 + }, + { + "type": "int", + "value": 7 + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someExternalStaticMethod" + } + ], + "uri": "package:record_use_test/external_function.dart" + }, + { + "path": [ + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someExternalFunction" + } + ], + "uri": "package:record_use_test/external_function.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation.", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_indices": [ + 0 + ], + "positional": [ + 1 + ], + "type": "with_arguments" + } + ] + }, + { + "definition_index": 1, + "uses": [ + { + "loading_unit_indices": [ + 0 + ], + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] + } + ] + } +} \ No newline at end of file