Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 675113002: Support async/await in the dart2js frontend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/warnings.dart
diff --git a/sdk/lib/_internal/compiler/implementation/warnings.dart b/sdk/lib/_internal/compiler/implementation/warnings.dart
index 42da42c399c1d449c62575c56906ca0f058e275c..d6945d2819ab634a6959fdecb21498602ebd525c 100644
--- a/sdk/lib/_internal/compiler/implementation/warnings.dart
+++ b/sdk/lib/_internal/compiler/implementation/warnings.dart
@@ -82,7 +82,13 @@ class MessageKind {
*/
final List examples;
- const MessageKind(this.template, {this.howToFix, this.examples});
+ /// Additional options needed for the examples to work.
+ final List<String> options;
+
+ const MessageKind(this.template,
+ {this.howToFix,
+ this.examples,
+ this.options: const <String>[]});
/// Do not use this. It is here for legacy and debugging. It violates item 4
/// above.
@@ -1976,6 +1982,105 @@ Please include the following information:
" require a preamble file located in:\n"
" <sdk>/lib/_internal/compiler/js_lib/preambles.");
+
+ static const MessageKind EXPERIMENTAL_ASYNC_AWAIT = const MessageKind(
+ "Experimental language feature 'async/await' is not supported.");
+
+ static const MessageKind INVALID_STARRED_KEYWORD = const MessageKind(
+ "Invalid '#{keyword}' keyword.",
+ options: const ['--enable-async'],
+ howToFix: "Try removing whitespace between '#{keyword}' and '*'.",
+ examples: const [
+ "main() async * {}",
+ "main() sync * {}",
+ "main() async* { yield * 0; }"
+ ]);
+
+ static const MessageKind INVALID_SYNC_MODIFIER = const MessageKind(
+ "Invalid modifier 'sync'.",
+ options: const ['--enable-async'],
+ howToFix: "Try replacing 'sync' with 'sync*'.",
+ examples: const [
+ "main() sync {}"
+ ]);
+
+ static const MessageKind INVALID_AWAIT_FOR = const MessageKind(
+ "'await' is only supported on for-in loops.",
+ options: const ['--enable-async'],
+ howToFix: "Try rewriting the loop as a for-in loop or removing the "
+ "'await' keyword.",
+ examples: const ["""
+main() async* {
+ await for (int i = 0; i < 10; i++) {}
+}
+"""]);
+
+ static const MessageKind ASYNC_MODIFIER_ON_ABSTRACT_METHOD =
+ const MessageKind(
+ "The modifier '#{modifier}' is not allowed on an abstract method.",
+ options: const ['--enable-async'],
+ howToFix: "Try removing the '#{modifier}' modifier or adding a "
+ "body to the method.",
+ examples: const ["""
+abstract class A {
+ method() async;
+}
+class B extends A {
+ method() {}
+}
+main() {
+ A a = new B();
+ a.method();
+}
+"""]);
+
+ static const MessageKind ASYNC_MODIFIER_ON_CONSTRUCTOR =
+ const MessageKind(
+ "The modifier '#{modifier}' is not allowed on constructors.",
+ options: const ['--enable-async'],
+ howToFix: "Try removing the '#{modifier}' modifier.",
+ examples: const ["""
+class A {
+ A() async;
+}
+main() => new A();""",
+
+"""
+class A {
+ A();
+ factory A.a() async* => new A();
+}
+main() => new A.a();"""]);
+
+ static const MessageKind YIELDING_MODIFIER_ON_ARROW_BODY =
+ const MessageKind(
+ "The modifier '#{modifier}' is not allowed on methods implemented "
+ "using '=>'.",
+ options: const ['--enable-async'],
+ howToFix: "Try removing the '#{modifier}' modifier or implementing "
+ "the method body using a block: '{ ... }'.",
+ examples: const ["main() sync* => null;", "main() async* => null;"]);
+
+ // TODO(johnniwinther): Check for 'async' as identifier.
+ static const MessageKind ASYNC_KEYWORD_AS_IDENTIFIER = const MessageKind(
+ "'#{keyword}' cannot be used as an identifier in a function body marked "
+ "with '#{modifier}'.",
+ options: const ['--enable-async'],
+ howToFix: "Try removing the '#{modifier}' modifier or renaming the "
+ "identifier.",
+ examples: const ["""
+main() async {
+ var await;
+}""",
+"""
+main() async* {
+ var yield;
+}""",
+"""
+main() sync* {
+ var yield;
+}"""]);
+
//////////////////////////////////////////////////////////////////////////////
// Patch errors start.
//////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/use_unused_api.dart ('k') | tests/compiler/dart2js/async_await_syntax.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698