Skip to content

Commit

Permalink
Revert "[dart2wasm] Check import/export pragmas in user code"
Browse files Browse the repository at this point in the history
This reverts commit 35bc17a.

Reason for revert: Breaking flutter web engine unit tests: flutter/flutter#149600

Original change's description:
> [dart2wasm] Check import/export pragmas in user code
>
> Change-Id: I926d108a4571d685c67d3a174a8e506910cce8f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369020
> Commit-Queue: Ömer Ağacan <[email protected]>
> Reviewed-by: Martin Kustermann <[email protected]>

Change-Id: Iba57910e7492abb7371172ecdb4fc2cc18fed66e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369500
Reviewed-by: Siva Annamalai <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
Commit-Queue: Jackson Gardner <[email protected]>
  • Loading branch information
eyebrowsoffire authored and Commit Queue committed Jun 3, 2024
1 parent 030b79d commit 9fa160b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 87 deletions.
11 changes: 0 additions & 11 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17641,17 +17641,6 @@ const MessageCode messageVoidWithTypeArguments = const MessageCode(
correctionMessage: r"""Try removing the type arguments.""",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeWasmImportOrExportInUserCode =
messageWasmImportOrExportInUserCode;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageWasmImportOrExportInUserCode = const MessageCode(
"WasmImportOrExportInUserCode",
problemMessage:
r"""Pragmas `wasm:import` and `wasm:export` are for internal use only and cannot be used by user code.""",
);

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeWeakReferenceMismatchReturnAndArgumentTypes =
messageWeakReferenceMismatchReturnAndArgumentTypes;
Expand Down
53 changes: 1 addition & 52 deletions pkg/dart2wasm/lib/target.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:_fe_analyzer_shared/src/messages/codes.dart'
show Message, LocatedMessage, messageWasmImportOrExportInUserCode;
show Message, LocatedMessage;
import 'package:_js_interop_checks/js_interop_checks.dart';
import 'package:_js_interop_checks/src/js_interop.dart' as jsInteropHelper;
import 'package:_js_interop_checks/src/transformations/shared_interop_transformer.dart';
Expand Down Expand Up @@ -243,11 +243,6 @@ class WasmTarget extends Target {
ReferenceFromIndex? referenceFromIndex,
{void Function(String msg)? logger,
ChangedStructureNotifier? changedStructureNotifier}) {
// Check `wasm:import` and `wasm:export` pragmas before FFI transforms as
// FFI transforms convert JS interop annotations to these pragmas.
_checkWasmImportExportPragmas(libraries, coreTypes,
diagnosticReporter as DiagnosticReporter<Message, LocatedMessage>);

Set<Library> transitiveImportingJSInterop = {
...jsInteropHelper.calculateTransitiveImportsOfJsInteropIfUsed(
component, Uri.parse("package:js/js.dart")),
Expand Down Expand Up @@ -523,49 +518,3 @@ class WasmVerification extends Verification {
return false;
}
}

final _dartCoreUri = Uri.parse('dart:core');

/// Check that `wasm:import` and `wasm:export` pragmas are only used in `dart:`
/// libraries and in tests, with the exception of
/// `reject_import_export_pragmas` test.
void _checkWasmImportExportPragmas(List<Library> libraries, CoreTypes coreTypes,
DiagnosticReporter<Message, LocatedMessage> diagnosticReporter) {
for (Library library in libraries) {
final importUri = library.importUri;
if (importUri.isScheme('dart') ||
(importUri.path.contains('tests/web/wasm') &&
!importUri.path.contains('reject_import_export_pragmas'))) {
continue;
}

for (Member member in library.members) {
for (Expression annotation in member.annotations) {
if (annotation is! ConstantExpression) {
continue;
}
final annotationConstant = annotation.constant;
if (annotationConstant is! InstanceConstant) {
continue;
}
final cls = annotationConstant.classNode;
if (cls.name == 'pragma' &&
cls.enclosingLibrary.importUri == _dartCoreUri) {
final pragmaName = annotationConstant
.fieldValues[coreTypes.pragmaName.fieldReference];
if (pragmaName is StringConstant) {
if (pragmaName.value == 'wasm:import' ||
pragmaName.value == 'wasm:export') {
diagnosticReporter.report(
messageWasmImportOrExportInUserCode,
annotation.fileOffset,
0,
library.fileUri,
);
}
}
}
}
}
}
}
2 changes: 0 additions & 2 deletions pkg/front_end/messages.status
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,6 @@ VarAsTypeName/part_wrapped_script1: Fail
VarAsTypeName/script1: Fail # Too many problems
VariableCouldBeNullDueToWrite/analyzerCode: Fail
VariableCouldBeNullDueToWrite/example: Fail
WasmImportOrExportInUserCode/analyzerCode: Fail
WasmImportOrExportInUserCode/example: Fail
WeakReferenceMismatchReturnAndArgumentTypes/analyzerCode: Fail
WeakReferenceMismatchReturnAndArgumentTypes/example: Fail
WeakReferenceNotOneArgument/analyzerCode: Fail
Expand Down
3 changes: 0 additions & 3 deletions pkg/front_end/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7011,9 +7011,6 @@ ResourceIdentifiersNotStatic:
ResourceIdentifiersMultiple:
problemMessage: "Only one resource identifier pragma can be used at a time."

WasmImportOrExportInUserCode:
problemMessage: "Pragmas `wasm:import` and `wasm:export` are for internal use only and cannot be used by user code."

WeakReferenceNotStatic:
problemMessage: "Weak reference pragma can be used on a static method only."

Expand Down
3 changes: 0 additions & 3 deletions pkg/front_end/test/spell_checking_list_messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ placing
pointer`s
pragma
pragma('vm:deeply
pragmas
preexisting
pubspec.yaml
r
Expand Down Expand Up @@ -150,6 +149,4 @@ u
unavailable
unsound
v
wasm:export
wasm:import
x
16 changes: 0 additions & 16 deletions tests/web/wasm/reject_import_export_pragmas_test.dart

This file was deleted.

0 comments on commit 9fa160b

Please sign in to comment.