Chromium Code Reviews| Index: tests/language_strong/generic_methods_overloading_test.dart |
| diff --git a/tests/language_strong/generic_methods_overloading_test.dart b/tests/language_strong/generic_methods_overloading_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6236700c3c377c13e4785ef075f2715de04b3ae4 |
| --- /dev/null |
| +++ b/tests/language_strong/generic_methods_overloading_test.dart |
| @@ -0,0 +1,43 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library generic_methods_boundaries_test; |
|
eernst
2017/03/09 14:55:03
Might as well use a library name that matches the
Dmitry Stefantsov
2017/03/10 13:21:54
Yep, the library name is wrong here. Thanks for th
|
| + |
| +import "package:expect/expect.dart"; |
| + |
| +class A {} |
| + |
| +class B extends A {} |
| + |
| +class C { |
| + String fun<T extends B>(T x) => "C"; |
| +} |
| + |
| +class D extends C { |
| + @override |
| + String fun<T extends A>(T x) { |
|
eernst
2017/03/09 14:55:03
I believe we have maintained that generic function
Leaf
2017/03/09 19:17:27
I had forgotten we'd agreed to this, but it seems
Dmitry Stefantsov
2017/03/10 13:21:54
Then I change it to multi-test to check for compil
|
| + if (x is B) { |
| + return super.fun<B>(x as B); |
|
Leaf
2017/03/09 05:51:19
Cast is unnecessary in strong mode.
asgerf
2017/03/09 10:36:51
It seems to me that 'B' is not more specific than
Leaf
2017/03/09 19:17:26
Currently in strong mode, if we have a type variab
asgerf
2017/03/10 09:20:24
Ah, I remember seeing that when adding strong mode
Dmitry Stefantsov
2017/03/10 13:21:54
I think I reorganize this, so that we have both ve
|
| + } |
| + return "D"; |
| + } |
| +} |
| + |
| +class E extends C { |
| + @override |
| + String fun<T>(B x) => "E"; |
|
eernst
2017/03/09 14:55:03
This would again be a compile time error, there mu
Dmitry Stefantsov
2017/03/10 13:21:54
Marked it as a compile-time error in multi-test. A
|
| +} |
| + |
| +main() { |
| + A a = new A(); |
| + B b = new B(); |
| + C c = new C(); |
| + D d = new D(); |
| + E e = new E(); |
| + |
| + Expect.isTrue(c.fun<B>(b) == "C"); |
| + Expect.isTrue(d.fun<A>(b) == "C"); |
| + Expect.isTrue(d.fun<A>(a) == "D"); |
| + Expect.isTrue(e.fun<B>(b) == "E"); |
| +} |