Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tests/language_strong/generic_methods_recursive_bound_test.dart

Issue 2765693002: Update all tests (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 F-bounded quantification works for generic methods, and that types 5 // Test that F-bounded quantification works for generic methods, and that types
6 // that are passed to generic methods in dynamic calls are checked for being 6 // that are passed to generic methods in dynamic calls are checked for being
7 // recursively defined. 7 // recursively defined.
8 8
9 library generic_methods_recursive_bound_test; 9 library generic_methods_recursive_bound_test;
10 10
11 import "package:expect/expect.dart"; 11 import "package:expect/expect.dart";
12 12
13 abstract class I<T> { 13 abstract class I<T> {
14 bool fun(T x); 14 bool fun(T x);
15 } 15 }
16 16
17 void foo<T extends I<T>>(List<T> a) { 17 void foo<T extends I<T>>(List<T> a) {
18 if (a.length > 1) { 18 if (a.length > 1) {
19 a[0].fun(a[1]); 19 a[0].fun(a[1]);
20 } 20 }
21 } 21 }
22 22
23 class C implements I<C> { 23 class C implements I<C> {
24 bool fun(C c) => true; 24 bool fun(C c) => true;
25 } 25 }
26 26
27 main() { 27 main() {
28 foo<C>(<C>[new C(), new C()]); /// 01: ok 28 foo<C>(<C>[new C(), new C()]); //# 01: ok
29 29
30 dynamic bar = foo; 30 dynamic bar = foo;
31 List<int> list2 = <int>[4, 2]; 31 List<int> list2 = <int>[4, 2];
32 // The type int does not extend I<int>. 32 // The type int does not extend I<int>.
33 foo<int>(list2); /// 02: compile-time error 33 foo<int>(list2); //# 02: compile-time error
34 bar<int>(list2); /// 03: runtime error 34 bar<int>(list2); //# 03: runtime error
35 } 35 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698