| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // VMOptions=--enable_checked_mode | 4 // VMOptions=--enable_checked_mode |
| 5 // Tests the type checking when passing code into closure from inside a factory
method | 5 // Tests the type checking when passing code into closure from inside a factory
method |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 abstract class Foo<T> { | 7 abstract class Foo<T> { |
| 10 factory Foo.from() = Bar<T>.from; | 8 factory Foo.from() = Bar<T>.from; |
| 11 } | 9 } |
| 12 | 10 |
| 13 class Bar<T> implements Foo<T> { | 11 class Bar<T> implements Foo<T> { |
| 14 Bar() {} | 12 Bar() {} |
| 15 | 13 |
| 16 factory Bar.from() { | 14 factory Bar.from() { |
| 17 var func = (T arg) { | 15 var func = (T arg) { |
| 18 T foo = arg; | 16 T foo = arg; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 | 30 |
| 33 bool gotError = false; | 31 bool gotError = false; |
| 34 | 32 |
| 35 try { | 33 try { |
| 36 Foo<int> value2 = new Foo<int>.from(); | 34 Foo<int> value2 = new Foo<int>.from(); |
| 37 } on TypeError catch (e) { | 35 } on TypeError catch (e) { |
| 38 gotError = true; | 36 gotError = true; |
| 39 } | 37 } |
| 40 Expect.equals(true, gotError); | 38 Expect.equals(true, gotError); |
| 41 } | 39 } |
| OLD | NEW |