OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:compiler/src/compiler.dart' show Compiler; | 5 import 'package:compiler/src/compiler.dart' show Compiler; |
6 import 'package:compiler/src/elements/elements.dart'; | 6 import 'package:compiler/src/elements/elements.dart'; |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 | 8 |
9 import 'helper.dart' show check; | 9 import 'helper.dart' show check; |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 class A { | 26 class A { |
27 int x = 1; | 27 int x = 1; |
28 } | 28 } |
29 | 29 |
30 main() { | 30 main() { |
31 var a = new A(); | 31 var a = new A(); |
32 return a; | 32 return a; |
33 }'''; | 33 }'''; |
34 return check(code, lookup: defaultConstructorFor('A')); | 34 return check(code, lookup: defaultConstructorFor('A')); |
35 }); | 35 }); |
| 36 |
| 37 test('redirecting constructor with field', () { |
| 38 String code = ''' |
| 39 class Foo { |
| 40 final int value; |
| 41 const Foo({int number: 0}) : this.poodle(number * 2); |
| 42 const Foo.poodle(this.value); |
| 43 } |
| 44 |
| 45 main() => new Foo(number: 3); |
| 46 '''; |
| 47 return check(code, lookup: defaultConstructorFor('Foo')); |
| 48 }); |
36 } | 49 } |
37 | 50 |
38 defaultConstructorFor(String className) => (Compiler compiler) { | 51 defaultConstructorFor(String className) => (Compiler compiler) { |
39 ClassElement clazz = compiler.mainApp.find(className); | 52 ClassElement clazz = compiler.mainApp.find(className); |
40 return clazz.lookupDefaultConstructor(); | 53 return clazz.lookupDefaultConstructor(); |
41 }; | 54 }; |
OLD | NEW |