OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017, 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 // Test that generic methods can be overridden using the bound of a type |
| 6 // variable as the type of the parameter in the overloaded method. |
| 7 |
| 8 library generic_methods_overriding_contravariance_test; |
| 9 |
| 10 import "test_base.dart"; |
| 11 |
| 12 class X {} |
| 13 |
| 14 class Y extends X {} |
| 15 |
| 16 class Z extends Y {} |
| 17 |
| 18 class C { |
| 19 String fun<T extends Y>(T t) => "C"; |
| 20 } |
| 21 |
| 22 class E extends C { |
| 23 String fun<T extends Y>(Y y) => "E"; |
| 24 } |
| 25 |
| 26 main() { |
| 27 Y y = new Y(); |
| 28 |
| 29 C c = new C(); |
| 30 E e = new E(); |
| 31 |
| 32 expectTrue(c.fun<Y>(y) == "C"); |
| 33 expectTrue(e.fun<Y>(y) == "E"); |
| 34 } |
OLD | NEW |