[dart2wasm] Report warning on sync*
Change-Id: If5b0492438830b8813d86a031193fa8d64ed1b1c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279017 Commit-Queue: Aske Simon Christensen <askesc@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
Commit Queue
parent
c1d75a63ab
commit
cffd49e97c
@@ -12365,6 +12365,14 @@ const MessageCode messageVoidWithTypeArguments = const MessageCode(
|
||||
problemMessage: r"""Type 'void' can't have type arguments.""",
|
||||
correctionMessage: r"""Try removing the type arguments.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeWasmSyncStar = messageWasmSyncStar;
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const MessageCode messageWasmSyncStar = const MessageCode("WasmSyncStar",
|
||||
severity: Severity.warning,
|
||||
problemMessage: r"""Compilation to Wasm does not support 'sync*'.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeWeakWithStrongDillLibrary =
|
||||
messageWeakWithStrongDillLibrary;
|
||||
|
||||
@@ -174,7 +174,8 @@ class WasmTarget extends Target {
|
||||
logger?.call("Transformed ffi annotations");
|
||||
}
|
||||
|
||||
wasmTrans.transformLibraries(libraries, coreTypes, hierarchy);
|
||||
wasmTrans.transformLibraries(
|
||||
libraries, coreTypes, hierarchy, diagnosticReporter);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,23 +5,28 @@
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
import 'package:kernel/core_types.dart';
|
||||
import 'package:kernel/target/targets.dart';
|
||||
import 'package:kernel/type_environment.dart';
|
||||
import 'package:kernel/type_algebra.dart';
|
||||
import 'package:_fe_analyzer_shared/src/messages/codes.dart'
|
||||
show messageWasmSyncStar;
|
||||
|
||||
void transformLibraries(
|
||||
List<Library> libraries, CoreTypes coreTypes, ClassHierarchy hierarchy) {
|
||||
final transformer = _WasmTransformer(coreTypes, hierarchy);
|
||||
void transformLibraries(List<Library> libraries, CoreTypes coreTypes,
|
||||
ClassHierarchy hierarchy, DiagnosticReporter diagnosticReporter) {
|
||||
final transformer =
|
||||
_WasmTransformer(coreTypes, hierarchy, diagnosticReporter);
|
||||
libraries.forEach(transformer.visitLibrary);
|
||||
}
|
||||
|
||||
void transformProcedure(
|
||||
Procedure procedure, CoreTypes coreTypes, ClassHierarchy hierarchy) {
|
||||
final transformer = _WasmTransformer(coreTypes, hierarchy);
|
||||
final transformer = _WasmTransformer(coreTypes, hierarchy, null);
|
||||
procedure.accept(transformer);
|
||||
}
|
||||
|
||||
class _WasmTransformer extends Transformer {
|
||||
final TypeEnvironment env;
|
||||
final DiagnosticReporter? diagnosticReporter;
|
||||
|
||||
Member? _currentMember;
|
||||
StaticTypeContext? _cachedTypeContext;
|
||||
@@ -43,7 +48,8 @@ class _WasmTransformer extends Transformer {
|
||||
|
||||
CoreTypes get coreTypes => env.coreTypes;
|
||||
|
||||
_WasmTransformer(CoreTypes coreTypes, ClassHierarchy hierarchy)
|
||||
_WasmTransformer(
|
||||
CoreTypes coreTypes, ClassHierarchy hierarchy, this.diagnosticReporter)
|
||||
: env = TypeEnvironment(coreTypes, hierarchy),
|
||||
_nonNullableTypeType = coreTypes.index
|
||||
.getClass('dart:core', '_Type')
|
||||
@@ -640,6 +646,10 @@ class _WasmTransformer extends Transformer {
|
||||
_enclosingIsAsyncStar = false;
|
||||
return super.visitFunctionNode(functionNode);
|
||||
} else {
|
||||
if (functionNode.dartAsyncMarker == AsyncMarker.SyncStar) {
|
||||
diagnosticReporter?.report(messageWasmSyncStar, functionNode.fileOffset,
|
||||
1, functionNode.location?.file);
|
||||
}
|
||||
bool previousEnclosing = _enclosingIsAsyncStar;
|
||||
TreeNode result = super.visitFunctionNode(functionNode);
|
||||
_enclosingIsAsyncStar = previousEnclosing;
|
||||
|
||||
@@ -984,6 +984,8 @@ VariableCouldBeNullDueToWrite/example: Fail
|
||||
VariablePatternTypeMismatchInSwitchHeads/analyzerCode: Fail
|
||||
VariablePatternTypeMismatchInSwitchHeads/part_wrapped_script: Crash
|
||||
VariablePatternTypeMismatchInSwitchHeads/script: Crash
|
||||
WasmSyncStar/analyzerCode: Fail
|
||||
WasmSyncStar/example: Fail
|
||||
WeakWithStrongDillLibrary/analyzerCode: Fail
|
||||
WeakWithStrongDillLibrary/example: Fail
|
||||
WebLiteralCannotBeRepresentedExactly/analyzerCode: Fail
|
||||
|
||||
@@ -1675,6 +1675,10 @@ YieldNotGenerator:
|
||||
problemMessage: "'yield' can only be used in 'sync*' or 'async*' methods."
|
||||
analyzerCode: YIELD_IN_NON_GENERATOR
|
||||
|
||||
WasmSyncStar:
|
||||
problemMessage: "Compilation to Wasm does not support 'sync*'."
|
||||
severity: WARNING
|
||||
|
||||
OnlyTry:
|
||||
index: 20
|
||||
problemMessage: "A try block must be followed by an 'on', 'catch', or 'finally' clause."
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
//
|
||||
// Problems outside component:
|
||||
//
|
||||
// pkg/front_end/testcases/dart2wasm/yield.dart: Warning: Compilation to Wasm does not support 'sync*'.
|
||||
//
|
||||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
Reference in New Issue
Block a user