OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015, 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 class Foo<T> { | |
6 T _t; | |
7 add(T t) { | |
8 _t = t; | |
9 } | |
10 | |
11 forEach(void fn(T t)) { | |
12 // No check needed for `fn` | |
13 fn(_t); | |
14 } | |
15 } | |
16 | |
17 class Bar extends Foo<int> { | |
18 add(int x) { | |
19 print('Bar.add got $x'); | |
20 super.add(x); | |
21 } | |
22 } | |
23 | |
24 main() { | |
25 Foo<Object> foo = new Bar(); | |
26 foo.add('hi'); // should throw | |
27 } | |
OLD | NEW |