| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Test that type parameters in generic methods can be shadowed. | 5 // Test that type parameters in generic methods can be shadowed. |
| 6 | 6 |
| 7 library generic_methods_shadowing_test; | 7 library generic_methods_shadowing_test; |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 | 10 |
| 11 class X {} | 11 class X {} |
| 12 | 12 |
| 13 class Y {} | 13 class Y {} |
| 14 | 14 |
| 15 bool foo<T, S>(T t, S s) { | 15 bool foo<T, S>(T t, S s) { |
| 16 // The type parameter T of bar shadows the type parameter T of foo. | 16 // The type parameter T of bar shadows the type parameter T of foo. |
| 17 bool bar<T>(T t) { | 17 bool bar<T>(T t) { |
| 18 return t is T && t is S; | 18 return t is T && t is S; |
| 19 } | 19 } |
| 20 | 20 |
| 21 return bar<S>(s); | 21 return bar<S>(s); |
| 22 } | 22 } |
| 23 | 23 |
| 24 main() { | 24 main() { |
| 25 Expect.isTrue(foo<X, Y>(new X(), new Y())); | 25 Expect.isTrue(foo<X, Y>(new X(), new Y())); |
| 26 } | 26 } |
| OLD | NEW |