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

Unified Diff: pkg/compiler/lib/src/diagnostics/messages.dart

Issue 1409033005: Add @anonymous annotation and restrict object literal constructors to only anonymous classes. This … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: ptal Created 5 years, 2 months 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/diagnostics/messages.dart
diff --git a/pkg/compiler/lib/src/diagnostics/messages.dart b/pkg/compiler/lib/src/diagnostics/messages.dart
index 810e88f9eb5987d2665ea407d243e04b78d09d12..09417957c7511f45110dd5bb1e5e0811758035ec 100644
--- a/pkg/compiler/lib/src/diagnostics/messages.dart
+++ b/pkg/compiler/lib/src/diagnostics/messages.dart
@@ -278,6 +278,8 @@ enum MessageKind {
INVALID_USE_OF_SUPER,
JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS,
JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER,
+ JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS,
+ JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS,
LIBRARY_NAME_MISMATCH,
LIBRARY_NOT_FOUND,
LIBRARY_NOT_SUPPORTED,
@@ -2172,6 +2174,51 @@ main() => A.A = 1;
}
"""]),
+ MessageKind.JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS:
+ const MessageTemplate(
+ MessageKind.JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS,
+ "Js-interop method '#{method}' has named arguments but is not "
+ "a factory constructor of an @anonymous @JS class.",
+ howToFix: "Remove all named arguments from js-interop method or "
+ "in the case of a factory constructor annotate the class "
+ "as @anonymous.",
+ examples: const [
+ """
+ import 'package:js/js.dart';
+
+ @JS()
+ class Foo {
+ external bar(foo, {baz});
+ }
+
+ main() {
+ new Foo().bar(4, baz: 5);
+ }
+ """]),
+
+ MessageKind.JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS:
+ const MessageTemplate(
+ MessageKind.JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS,
+ "Parameter '#{parameter}' in anonymous js-interop class '#{cls}' "
+ "object literal constructor is positional instead of named."
+ ".",
+ howToFix: "Make all arguments in external factory object literal "
+ "constructors named.",
+ examples: const [
+ """
+ import 'package:js/js.dart';
+
+ @anonymous
+ @JS()
+ class Foo {
+ external factory Foo(foo, {baz});
+ }
+
+ main() {
+ new Foo(5, baz: 5);
+ }
+ """]),
+
MessageKind.LIBRARY_NOT_FOUND:
const MessageTemplate(MessageKind.LIBRARY_NOT_FOUND,
"Library not found '#{resolvedUri}'."),
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698