OLD | NEW |
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 T run<T>(T f()) { | 8 T run<T>(T f()) { |
9 print("running"); | 9 print("running"); |
10 var /*@type=run::T*/ t = f(); | 10 var /*@type=run::T*/ t = f(); |
11 print("done running"); | 11 print("done running"); |
12 return t; | 12 return t; |
13 } | 13 } |
14 | 14 |
15 void printRunning() { | 15 void printRunning() { |
16 print("running"); | 16 print("running"); |
17 } | 17 } |
18 | 18 |
19 var /*@topType=dynamic*/ x = run<dynamic>(printRunning); | 19 var /*@topType=dynamic*/ x = run<dynamic>(printRunning); |
20 var /*@topType=dynamic*/ y = /*info:USE_OF_VOID_RESULT, error:TOP_LEVEL_TYPE_ARG
UMENTS*/ /*@typeArgs=void*/ run( | |
21 printRunning); | |
22 | 20 |
23 main() { | 21 main() { |
24 void printRunning() { | 22 void printRunning() { |
25 print("running"); | 23 print("running"); |
26 } | 24 } |
27 | 25 |
28 var /*@type=dynamic*/ x = run<dynamic>(printRunning); | 26 var /*@type=dynamic*/ x = run<dynamic>(printRunning); |
29 var /*@type=void*/ y = /*info:USE_OF_VOID_RESULT*/ /*@typeArgs=void*/ run( | 27 var /*@type=void*/ y = /*info:USE_OF_VOID_RESULT*/ /*@typeArgs=void*/ run( |
30 printRunning); | 28 printRunning); |
31 x = 123; | 29 x = 123; |
32 x = 'hi'; | 30 x = 'hi'; |
33 y = /*error:INVALID_ASSIGNMENT*/ 123; | 31 y = /*error:INVALID_ASSIGNMENT*/ 123; |
34 y = /*error:INVALID_ASSIGNMENT*/ 'hi'; | 32 y = /*error:INVALID_ASSIGNMENT*/ 'hi'; |
35 } | 33 } |
OLD | NEW |