OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 class Base { | 7 class Base { |
8 int i, j; | 8 int i, j; |
9 Base.ctor(int this.i | 9 Base.ctor(int this.i |
10 , {int this.j: 10} /// 01: compile-time error | 10 , {int this.j: 10} // /// 01: compile-time error |
11 ) { | 11 ) { |
12 if (j == null) { | 12 if (j == null) { |
13 j = 10; | 13 j = 10; |
14 } | 14 } |
15 } | 15 } |
16 } | 16 } |
17 | 17 |
18 abstract class M { | 18 abstract class M { |
19 get i; | 19 get i; |
20 get j; | 20 get j; |
21 int k = 42; | 21 int k = 42; |
22 foo() => i + j; | 22 foo() => i + j; |
23 } | 23 } |
24 | 24 |
25 class C extends Base with M { | 25 class C extends Base with M { |
26 int l = 131; | 26 int l = 131; |
27 C.foo() : super.ctor(1, j: 13); /// 01: compile-time error | 27 C.foo() : super.ctor(1, j: 13); /// 01: compile-time error |
28 C.bar() : super.ctor(1); | 28 C.bar() : super.ctor(1); |
29 } | 29 } |
30 | 30 |
31 main() { | 31 main() { |
32 C c1 = new C.foo(); /// 01: compile-time error | 32 C c1 = new C.foo(); // /// 01: compile-time error |
33 C c2 = new C.bar(); | 33 C c2 = new C.bar(); |
34 Expect.equals(1, c2.i); | 34 Expect.equals(1, c2.i); |
35 Expect.equals(10, c2.j); | 35 Expect.equals(10, c2.j); |
36 Expect.equals(11, c2.foo()); | 36 Expect.equals(11, c2.foo()); |
37 Expect.equals(42, c2.k); | 37 Expect.equals(42, c2.k); |
38 Expect.equals(131, c2.l); | 38 Expect.equals(131, c2.l); |
39 } | 39 } |
OLD | NEW |