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

Unified Diff: tests/language/constructor_redirect2_test.dart

Issue 11293020: Redirecting constructor may not have function body (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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 | « no previous file | tests/language/constructor_redirect3_negative_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/constructor_redirect2_test.dart
===================================================================
--- tests/language/constructor_redirect2_test.dart (revision 0)
+++ tests/language/constructor_redirect2_test.dart (revision 0)
@@ -0,0 +1,29 @@
+// Copyright (c) 2012, 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.
+// Redirection constructors must not have a function body.
+
+class A {
+ var x;
+ A(this.x) {}
+
+ // Redirecting constructor must not have a function body.
+ A.illegalBody(x) : this(3) {} /// 01: compile-time error
+
+ // Redirecting constructor must not initialize any fields.
+ A.illegalInit() : this(3), x = 5; /// 02: compile-time error
+
+ // Redirecting constructor must not have initializing formal parameters.
+ A.illegalFormal(this.x) : this(3); /// 03: compile-time error
+
+ // Redirection constructors must not call super constructor.
+ A.illegalSuper() : this(3), super(3); /// 04: compile-time error
+}
+
+main() {
+ new A(3);
+ new A.illegalBody(10); /// 01: continued
+ new A.illegalInit(10); /// 02: continued
+ new A.illegalFormal(10); /// 03: continued
+ new A.illegalSuper(10); /// 04: continued
+}
« no previous file with comments | « no previous file | tests/language/constructor_redirect3_negative_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698