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

Unified Diff: tests/language/initializing_formal_scope_test.dart

Issue 2059883002: Implementation of modified scoping for initializing formals. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Review response Created 4 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/compiler/dart2js/message_kind_helper.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/initializing_formal_scope_test.dart
diff --git a/tests/language/initializing_formal_capture_test.dart b/tests/language/initializing_formal_scope_test.dart
similarity index 54%
copy from tests/language/initializing_formal_capture_test.dart
copy to tests/language/initializing_formal_scope_test.dart
index 7ad3f083cc185754bd31b937bbfba57421445846..dd85fada3582b3f8f946eb73ee5084768871d976 100644
--- a/tests/language/initializing_formal_capture_test.dart
+++ b/tests/language/initializing_formal_scope_test.dart
@@ -6,14 +6,20 @@
import "package:expect/expect.dart";
+// Duplicate definition checks for `this.x` will check the scopes associated
+// with the constructor, not all enclosing scopes; so this is not a conflict.
+var x;
+
class A {
- var x, y;
- A(this.x) : y = (() => x);
+ var x;
+ A(this.x) {
+ // In the body the field is in scope, not the initializing formal;
+ // so we can use the setter.
+ x += 1;
+ }
}
main() {
A a = new A(2);
- a.x = 3;
Expect.equals(a.x, 3);
- Expect.equals(a.y(), 2);
}
« no previous file with comments | « tests/compiler/dart2js/message_kind_helper.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698