Index: pkg/dev_compiler/test/codegen/language/initializing_formal_final_test.dart |
diff --git a/pkg/dev_compiler/test/codegen/language/initializing_formal_final_test.dart b/pkg/dev_compiler/test/codegen/language/initializing_formal_final_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3df4ba521c2db29e46d7a860bec5e84845546805 |
--- /dev/null |
+++ b/pkg/dev_compiler/test/codegen/language/initializing_formal_final_test.dart |
@@ -0,0 +1,21 @@ |
+// Copyright (c) 2016, 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. |
+// |
+// DartOptions=--initializing-formal-access |
+// VMOptions=--initializing-formal-access |
+ |
+import "package:expect/expect.dart"; |
+ |
+class A { |
+ var x, y; |
+ // This should cause a warning because `x` is final when |
+ // accessed as an initializing formal. |
vsm
2016/11/29 23:00:57
Erik: This should be an error in strong mode, righ
eernst
2016/11/30 10:22:46
Right, `dartanalyzer --strong ..` considers assign
|
+ A(this.x) : y = (() { x = 3; }); |
+} |
+ |
+main() { |
+ A a = new A(2); |
+ Expect.equals(a.x, 2); |
+ Expect.throws(() => a.y(), (e) => e is NoSuchMethodError); |
+} |