Chromium Code Reviews| 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 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
| |
| 6 | |
| 7 import "package:expect/expect.dart"; | |
| 8 | |
| 9 class A {} | |
| 10 | |
| 11 class B extends A {} | |
| 12 | |
| 13 class C { | |
| 14 String fun<T extends B>(T x) => "C"; | |
| 15 } | |
| 16 | |
| 17 class D extends C { | |
| 18 @override | |
| 19 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
| |
| 20 if (x is B) { | |
| 21 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
| |
| 22 } | |
| 23 return "D"; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 class E extends C { | |
| 28 @override | |
| 29 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
| |
| 30 } | |
| 31 | |
| 32 main() { | |
| 33 A a = new A(); | |
| 34 B b = new B(); | |
| 35 C c = new C(); | |
| 36 D d = new D(); | |
| 37 E e = new E(); | |
| 38 | |
| 39 Expect.isTrue(c.fun<B>(b) == "C"); | |
| 40 Expect.isTrue(d.fun<A>(b) == "C"); | |
| 41 Expect.isTrue(d.fun<A>(a) == "D"); | |
| 42 Expect.isTrue(e.fun<B>(b) == "E"); | |
| 43 } | |
| OLD | NEW |