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

Unified Diff: tests/language/prefix_assignment_test.dart

Issue 1173523002: Fix analyzer's handling of import prefixes not followed by '.'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « tests/language/language_dart2js.status ('k') | tests/language/prefix_identifier_reference_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/prefix_assignment_test.dart
diff --git a/tests/language/prefix_assignment_test.dart b/tests/language/prefix_assignment_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d9ec0991aa15ef5c71baf61196f1bd2c0b1236d2
--- /dev/null
+++ b/tests/language/prefix_assignment_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Validate that assignment to a prefix is handled consistently with the
+// following spec text from section 16.19 (Assignment):
+// Evaluation of an assignment a of the form v = e proceeds as follows:
+// Let d be the innermost declaration whose name is v or v=, if it exists.
+// If d is the declaration of a local variable, ...
+// If d is the declaration of a library variable, ...
+// Otherwise, if d is the declaration of a static variable, ...
+// Otherwise, if a ocurs inside a top level or static function (be it
+// function, method, getter, or setter) or variable initializer, evaluation
+// of a causes e to be evaluated, after which a NoSuchMethodError is thrown.
+// Otherwise, the assignment is equivalent to the assignment this.v = e.
+//
+// Therefore, if p is an import prefix, evaluation of "p = ..." should be
+// equivalent to "this.p = ..." inside a method, and should produce a
+// NoSuchMethodError outside a method.
+
+import "package:expect/expect.dart";
+import "empty_library.dart" as p;
+
+class Base {
+ var p;
+}
+
+class Derived extends Base {
+ void f() {
+ p = 1; Expect.equals(1, this.p); /// 01: ok
+ }
+}
+
+bool gCalled = false;
+
+g() {
+ gCalled = true;
+ return 1;
+}
+
+noMethod(e) => e is NoSuchMethodError;
+
+main() {
+ new Derived().f();
+ Expect.throws(() { p = g(); }, noMethod); Expect.isTrue(gCalled); /// 02: static type warning
+}
« no previous file with comments | « tests/language/language_dart2js.status ('k') | tests/language/prefix_identifier_reference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698