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

Unified Diff: tests/language/constructor_duplicate_final_test.dart

Issue 505033002: Initializing a final instance is a runtime error (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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/co19/co19-runtime.status ('k') | tests/language/language_analyzer.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/constructor_duplicate_final_test.dart
===================================================================
--- tests/language/constructor_duplicate_final_test.dart (revision 0)
+++ tests/language/constructor_duplicate_final_test.dart (working copy)
@@ -0,0 +1,24 @@
+// Copyright (c) 2014, 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.
+
+// Check that duplicate initialization of a final field is a runtime error.
+
+
+class Class {
+ final f = 10;
+
+ Class(v) : f = v; /// 01: runtime error, static type warning
+
+ Class(this.f); /// 02: runtime error, static type warning
+
+ // If a field is initialized multiple times in the initializer
+ // list, it's a compile time error.
+ Class(this.f) : f = 0; /// 03: compile-time error
+}
+
+main() {
+ new Class(5); /// 01: continued
+ new Class(5); /// 02: continued
+ new Class(5); /// 03: continued
+}
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | tests/language/language_analyzer.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698