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

Side by Side Diff: tests/language/const_constructor_super_test.dart

Issue 18558002: Const constructor must have const super initializer (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6
7 class A {
8 final a;
9 A(this.a); // Not const.
10 const A.five() : a = 5;
11 }
12
13 class B extends A {
14 final b;
15 B(x) : b = x + 1, super(x);
16
17 // Const constructor cannot call non-const super constructor.
18 const B.zerofive() : b = 0, super(5); /// 01: compile-time error
19 }
20
21 class C extends A {
22 C() : super(0);
23 // Implicit call to non-const constructor A(x).
24 const C.named(x); /// 02: compile-time error
25 }
26
27 main() {
28 var b = new B.zerofive(); /// 01: continued
29 var b1 = new B(0);
30 var c = new C.named(""); /// 02: continued
31 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698