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

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

Issue 2865623003: Implement type inference of constructor invocations in Fasta. (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
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 /*@testedFeatures=inference*/ 5 /*@testedFeatures=inference*/
6 library test; 6 library test;
7 7
8 import 'dart:math'; 8 import 'dart:math';
9 9
10 void printInt(int x) => print(x); 10 void printInt(int x) => print(x);
11 void printDouble(double x) => print(x); 11 void printDouble(double x) => print(x);
12 12
13 num myMax(num x, num y) => max(x, y); 13 num myMax(num x, num y) => max(x, y);
14 14
15 main() { 15 f() {
16 // Okay if static types match. 16 // Okay if static types match.
17 printInt(max(1, 2)); 17 printInt(max(1, 2));
18 printInt(min(1, 2)); 18 printInt(min(1, 2));
19 printDouble(max(1.0, 2.0)); 19 printDouble(max(1.0, 2.0));
20 printDouble(min(1.0, 2.0)); 20 printDouble(min(1.0, 2.0));
21 21
22 // No help for user-defined functions from num->num->num. 22 // No help for user-defined functions from num->num->num.
23 printInt(/*info:DOWN_CAST_IMPLICIT*/ myMax(1, 2)); 23 printInt(/*info:DOWN_CAST_IMPLICIT*/ myMax(1, 2));
24 printInt(myMax(1, 2) as int); 24 printInt(myMax(1, 2) as int);
25 25
26 // Mixing int and double means return type is num. 26 // Mixing int and double means return type is num.
27 printInt(max(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 2.0)); 27 printInt(max(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 2.0));
28 printInt(min(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 2.0)); 28 printInt(min(1, /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 2.0));
29 printDouble(max(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 1, 2.0)); 29 printDouble(max(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 1, 2.0));
30 printDouble(min(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 1, 2.0)); 30 printDouble(min(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ 1, 2.0));
31 31
32 // Types other than int and double are not accepted. 32 // Types other than int and double are not accepted.
33 printInt(min( 33 printInt(min(
34 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ "hi", 34 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ "hi",
35 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ "there")); 35 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/ "there"));
36 } 36 }
37
38 main() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698