| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "package:expect/expect.dart"; | |
| 6 import 'package:meta/meta.dart' show checked; | |
| 7 | |
| 8 // Test runtime behavior of @checked | |
| 9 | |
| 10 class View { | |
| 11 addChild(View v) {} | |
| 12 transform(View fn(View v)) {} | |
| 13 } | |
| 14 class MyView extends View { | |
| 15 addChild(@checked MyView v) {} | |
| 16 transform(@checked MyView fn(Object v)) {} | |
| 17 } | |
| 18 | |
| 19 main() { | |
| 20 dynamic mv = new MyView(); | |
| 21 dynamic v = new View(); | |
| 22 | |
| 23 mv.addChild(mv); | |
| 24 Expect.throws(() => mv.addChild(v)); | |
| 25 | |
| 26 mv.transform((_) => new MyView()); | |
| 27 | |
| 28 // TODO(jmesserly): these *should* be a cast failures, but DDC is currently | |
| 29 // ignoring function type failures w/ a warning at the console... | |
| 30 | |
| 31 // * -> * not a subtype of Object -> MyView | |
| 32 // Expect.throws(() => mv.transform((_) => mv)); | |
| 33 | |
| 34 // View -> View not a subtype of Object -> MyView | |
| 35 // Expect.throws(() => mv.transform((View x) => x)); | |
| 36 } | |
| OLD | NEW |