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

Side by Side Diff: tests/language_2/type_variable_bounds_test.dart

Issue 3007803002: Migrate block 162 to Dart 2.0.
Patch Set: Created 3 years, 3 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 of parameterized factory methods. 5 // Test of parameterized factory methods.
6 6
7 class Foo<T extends num> { 7 class Foo<T extends num> {
8 Foo(); 8 Foo();
9 9
10 factory Foo.bad() = XFoo; // //# 00: static type warning 10 factory Foo.bad() = XFoo; //# 00: compile-time error
11 11
12 factory Foo.good() = Foo; 12 factory Foo.good() = Foo<T>;
13 13
14 factory Foo.IFoo() { 14 factory Foo.IFoo() {
15 return null; 15 return null;
16 } 16 }
17 } 17 }
18 18
19 abstract class IFoo<T extends num> { 19 abstract class IFoo<T extends num> {
20 factory IFoo() = Foo<T>; 20 factory IFoo() = Foo<T>; //# 11: compile-time error
21 } 21 }
22 22
23 // String is not assignable to num. 23 // String is not assignable to num.
24 class Baz 24 class Baz
25 extends Foo<String> //# 01: static type warning, dynamic type error 25 extends Foo<String> //# 01: compile-time error
26 {} 26 {}
27 27
28 class Biz extends Foo<int> {} 28 class Biz extends Foo<int> {}
29 29
30 Foo<int> fi; 30 Foo<int> fi;
31 31
32 // String is not assignable to num. 32 // String is not assignable to num.
eernst 2017/09/04 17:05:02 The actual type argument in the type annotation `F
33 Foo 33 Foo
34 <String> //# 02: static type warning, dynamic type error 34 <String> //# 02: compile-time error
35 fs; 35 fs;
36 36
37 class Box<T> { 37 class Box<T> {
38 // Box.T is not assignable to num. 38 // Box.T is not assignable to num.
eernst 2017/09/04 17:05:02 Same issue: adjust to `Box.T is not guaranteed to
39 Foo<T> t; //# 03: static type warning 39 Foo<T> t; //# 03: compile-time error
40 40
41 makeFoo() { 41 makeFoo() {
42 // Box.T is not assignable to num. 42 // Box.T is not assignable to num.
eernst 2017/09/04 17:05:02 Same again.
43 return new Foo<T>(); //# 04: static type warning, dynamic type error 43 return new Foo<T>(); //# 04: compile-time error
44 } 44 }
45 } 45 }
46 46
47 main() { 47 main() {
48 // String is not assignable to num. 48 // String is not assignable to num.
eernst 2017/09/04 17:05:02 Same again: `String is not a subtype of num`.
49 var v1 = new Foo<String>(); //# 05: static type warning, dynamic type error 49 var v1 = new Foo<String>(); //# 05: compile-time error
50 50
51 // String is not assignable to num. 51 // String is not assignable to num.
eernst 2017/09/04 17:05:02 Same again.
52 Foo<String> v2 = null; //# 06: static type warning 52 Foo<String> v2 = null; //# 06: compile-time error
53 53
54 new Baz(); 54 new Baz();
55 new Biz(); 55 new Biz();
56 56
57 fi = new Foo(); 57 fi = new Foo();
58 fs = new Foo(); 58 fs = new Foo();
59 59
60 new Box().makeFoo(); 60 new Box().makeFoo();
61 new Box<int>().makeFoo(); 61 new Box<int>().makeFoo();
62 new Box<String>().makeFoo(); 62 new Box<String>().makeFoo();
63 63
64 // Fisk does not exist. 64 // Fisk does not exist.
65 new Box<Fisk>(); //# 07: static type warning 65 new Box<Fisk>(); //# 07: compile-time error
66 66
67 // Too many type arguments. 67 // Too many type arguments.
68 new Box<Object, Object>(); //# 08: static type warning 68 new Box<Object, Object>(); //# 08: compile-time error
69 69
70 // Fisk does not exist. 70 // Fisk does not exist.
71 Box<Fisk> box = null; //# 09: static type warning 71 Box<Fisk> box = null; //# 09: compile-time error
72 72
73 // Too many type arguments. 73 // Too many type arguments.
74 Box<Object, Object> box = null; //# 10: static type warning 74 Box<Object, Object> box = null; //# 10: compile-time error
75 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698