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

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

Powered by Google App Engine
This is Rietveld 408576698