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

Side by Side Diff: pkg/front_end/testcases/inference/generic_methods_infer_generic_instantiation.dart

Issue 2846103002: Generated front_end/testcases/inference test files from Analyzer tests. (Closed)
Patch Set: Created 3 years, 7 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) 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 /*@testedFeatures=inference*/
6 library test;
7
8 import 'dart:math' as math;
9 import 'dart:math' show min;
10
11 class C {
12 T m<T extends num>(T x, T y) => null;
13 }
14
15 main() {
16 takeIII(math.max);
17 takeDDD(math.max);
18 takeNNN(math.max);
19 takeIDN(math.max);
20 takeDIN(math.max);
21 takeIIN(math.max);
22 takeDDN(math.max);
23 takeIIO(math.max);
24 takeDDO(math.max);
25
26 takeOOI(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);
27 takeIDI(
28 /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);
29 takeDID(
30 /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ math.max);
31 takeOON(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);
32 takeOOO(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ math.max);
33
34 // Also test SimpleIdentifier
35 takeIII(min);
36 takeDDD(min);
37 takeNNN(min);
38 takeIDN(min);
39 takeDIN(min);
40 takeIIN(min);
41 takeDDN(min);
42 takeIIO(min);
43 takeDDO(min);
44
45 takeOOI(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);
46 takeIDI(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);
47 takeDID(/*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ min);
48 takeOON(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);
49 takeOOO(/*error:COULD_NOT_INFER,error:INVALID_CAST_FUNCTION*/ min);
50
51 // Also PropertyAccess
52 takeIII(new C().m);
53 takeDDD(new C().m);
54 takeNNN(new C().m);
55 takeIDN(new C().m);
56 takeDIN(new C().m);
57 takeIIN(new C().m);
58 takeDDN(new C().m);
59 takeIIO(new C().m);
60 takeDDO(new C().m);
61
62 // Note: this is a warning because a downcast of a method tear-off could work
63 // (derived method can be a subtype):
64 //
65 // class D extends C {
66 // S m<S extends num>(Object x, Object y);
67 // }
68 //
69 // That's legal because we're loosening parameter types.
70 //
71 // We do issue the inference error though, similar to generic function calls.
72 takeOON(/*error:COULD_NOT_INFER,info:DOWN_CAST_COMPOSITE*/ new C().m);
73 takeOOO(/*error:COULD_NOT_INFER,info:DOWN_CAST_COMPOSITE*/ new C().m);
74
75 // Note: this is a warning because a downcast of a method tear-off could work
76 // in "normal" Dart, due to bivariance.
77 //
78 // We do issue the inference error though, similar to generic function calls.
79 takeOOI(/*error:COULD_NOT_INFER,info:DOWN_CAST_COMPOSITE*/ new C().m);
80
81 takeIDI(
82 /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ new C().m);
83 takeDID(
84 /*error:COULD_NOT_INFER,error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ new C().m);
85 }
86
87 void takeIII(int fn(int a, int b)) {}
88 void takeDDD(double fn(double a, double b)) {}
89 void takeIDI(int fn(double a, int b)) {}
90 void takeDID(double fn(int a, double b)) {}
91 void takeIDN(num fn(double a, int b)) {}
92 void takeDIN(num fn(int a, double b)) {}
93 void takeIIN(num fn(int a, int b)) {}
94 void takeDDN(num fn(double a, double b)) {}
95 void takeNNN(num fn(num a, num b)) {}
96 void takeOON(num fn(Object a, Object b)) {}
97 void takeOOO(num fn(Object a, Object b)) {}
98 void takeOOI(int fn(Object a, Object b)) {}
99 void takeIIO(Object fn(int a, int b)) {}
100 void takeDDO(Object fn(double a, double b)) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698