| 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 // Test that parameter default values are disallowed in a redirecting factory. | 5 // Test that parameter default values are disallowed in a redirecting factory. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 | 8 |
| 9 class A { | 9 class A { |
| 10 A(this.a, [this.b = 0]); | 10 A(this.a, [this.b = 0]); |
| 11 factory A.f(a) = A; | 11 factory A.f(a) = A; |
| 12 factory A.g(a, [b = 0]) = A; // /// 01: compile-time error | 12 factory A.g(a, [b = 0]) = A; // //# 01: compile-time error |
| 13 factory A.h(a, {b: 0}) = A; // /// 02: compile-time error | 13 factory A.h(a, {b: 0}) = A; // //# 02: compile-time error |
| 14 | 14 |
| 15 int a; | 15 int a; |
| 16 int b; | 16 int b; |
| 17 } | 17 } |
| 18 | 18 |
| 19 main() { | 19 main() { |
| 20 var x = new A.f(42); | 20 var x = new A.f(42); |
| 21 Expect.equals(x.a, 42); | 21 Expect.equals(x.a, 42); |
| 22 Expect.equals(x.b, 0); | 22 Expect.equals(x.b, 0); |
| 23 | 23 |
| 24 var y = new A.f(42, 43); | 24 var y = new A.f(42, 43); |
| 25 Expect.equals(y.a, 42); | 25 Expect.equals(y.a, 42); |
| 26 Expect.equals(y.b, 43); | 26 Expect.equals(y.b, 43); |
| 27 } | 27 } |
| OLD | NEW |