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

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

Issue 1651933002: Report error on JS-interop operator [] and []= methods. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Sort MessageKinds. Created 4 years, 11 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 | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/js_backend/backend.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 f394bdf5cc93bfbfefbfb08d01ee470b8e7c023a..b8a588a0ba904f7b6484b3b51d33436caa253258 100644
--- a/pkg/compiler/lib/src/diagnostics/messages.dart
+++ b/pkg/compiler/lib/src/diagnostics/messages.dart
@@ -290,8 +290,9 @@ enum MessageKind {
INVALID_YIELD,
JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS,
JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER,
- JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS,
+ JS_INTEROP_INDEX_NOT_SUPPORTED,
JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS,
+ JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS,
JS_PLACEHOLDER_CAPTURE,
LIBRARY_NAME_MISMATCH,
LIBRARY_NOT_FOUND,
@@ -2336,6 +2337,36 @@ main() => A.A = 1;
new Foo().bar(4, baz: 5);
}
"""]),
+ MessageKind.JS_INTEROP_INDEX_NOT_SUPPORTED:
+ const MessageTemplate(
+ MessageKind.JS_INTEROP_INDEX_NOT_SUPPORTED,
+ "Js-interop does not support [] and []= operator methods.",
+ howToFix: "Try replacing [] and []= operator methods with normal "
+ "methods.",
+ examples: const [
+ """
+ import 'package:js/js.dart';
+
+ @JS()
+ class Foo {
+ external operator [](arg);
+ }
+
+ main() {
+ new Foo()[0];
+ }
+ """, """
+ import 'package:js/js.dart';
+
+ @JS()
+ class Foo {
+ external operator []=(arg, value);
+ }
+
+ main() {
+ new Foo()[0] = 1;
+ }
+ """]),
MessageKind.JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS:
const MessageTemplate(
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698