OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.test.generated.non_error_resolver_test; | 5 library analyzer.test.generated.non_error_resolver_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 class A { | 2177 class A { |
2178 noSuchMethod(inv) {} | 2178 noSuchMethod(inv) {} |
2179 } | 2179 } |
2180 class B extends A implements Function { | 2180 class B extends A implements Function { |
2181 }'''); | 2181 }'''); |
2182 await computeAnalysisResult(source); | 2182 await computeAnalysisResult(source); |
2183 assertNoErrors(source); | 2183 assertNoErrors(source); |
2184 verify([source]); | 2184 verify([source]); |
2185 } | 2185 } |
2186 | 2186 |
| 2187 test_genericTypeAlias_castsAndTypeChecks_hasTypeParameters() async { |
| 2188 Source source = addSource(''' |
| 2189 typedef Foo<S> = S Function<T>(T x); |
| 2190 |
| 2191 main(Object p) { |
| 2192 (p as Foo)<int>(3); |
| 2193 if (p is Foo) { |
| 2194 p<int>(3); |
| 2195 } |
| 2196 (p as Foo<String>)<int>(3); |
| 2197 if (p is Foo<String>) { |
| 2198 p<int>(3); |
| 2199 } |
| 2200 } |
| 2201 '''); |
| 2202 await computeAnalysisResult(source); |
| 2203 assertNoErrors(source); |
| 2204 verify([source]); |
| 2205 } |
| 2206 |
| 2207 test_genericTypeAlias_castsAndTypeChecks_noTypeParameters() async { |
| 2208 Source source = addSource(''' |
| 2209 typedef Foo = T Function<T>(T x); |
| 2210 |
| 2211 main(Object p) { |
| 2212 (p as Foo)<int>(3); |
| 2213 if (p is Foo) { |
| 2214 p<int>(3); |
| 2215 } |
| 2216 } |
| 2217 '''); |
| 2218 await computeAnalysisResult(source); |
| 2219 assertNoErrors(source); |
| 2220 verify([source]); |
| 2221 } |
| 2222 |
2187 test_genericTypeAlias_fieldAndReturnType_noTypeParameters() async { | 2223 test_genericTypeAlias_fieldAndReturnType_noTypeParameters() async { |
2188 Source source = addSource(r''' | 2224 Source source = addSource(r''' |
2189 typedef Foo = int Function<T>(T x); | 2225 typedef Foo = int Function<T>(T x); |
2190 int foo<T>(T x) => 3; | 2226 int foo<T>(T x) => 3; |
2191 Foo bar() => foo; | 2227 Foo bar() => foo; |
2192 void test1() { | 2228 void test1() { |
2193 bar()<String>("hello"); | 2229 bar()<String>("hello"); |
2194 } | 2230 } |
2195 | 2231 |
2196 class A { | 2232 class A { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 void test() { | 2276 void test() { |
2241 f<String>("hello"); | 2277 f<String>("hello"); |
2242 } | 2278 } |
2243 } | 2279 } |
2244 '''); | 2280 '''); |
2245 await computeAnalysisResult(source); | 2281 await computeAnalysisResult(source); |
2246 assertNoErrors(source); | 2282 assertNoErrors(source); |
2247 verify([source]); | 2283 verify([source]); |
2248 } | 2284 } |
2249 | 2285 |
| 2286 test_genericTypeAlias_invalidGenericFunctionType() async { |
| 2287 Source source = addSource(''' |
| 2288 typedef F = int; |
| 2289 main(p) { |
| 2290 p is F; |
| 2291 } |
| 2292 '''); |
| 2293 await computeAnalysisResult(source); |
| 2294 // There is a parse error, but no crashes. |
| 2295 assertErrors(source, [ParserErrorCode.INVALID_GENERIC_FUNCTION_TYPE]); |
| 2296 verify([source]); |
| 2297 } |
| 2298 |
2250 test_genericTypeAlias_noTypeParameters() async { | 2299 test_genericTypeAlias_noTypeParameters() async { |
2251 Source source = addSource(r''' | 2300 Source source = addSource(r''' |
2252 typedef Foo = int Function<T>(T x); | 2301 typedef Foo = int Function<T>(T x); |
2253 int foo<T>(T x) => 3; | 2302 int foo<T>(T x) => 3; |
2254 void test1() { | 2303 void test1() { |
2255 Foo y = foo; | 2304 Foo y = foo; |
2256 // These two should be equivalent | 2305 // These two should be equivalent |
2257 foo<String>("hello"); | 2306 foo<String>("hello"); |
2258 y<String>("hello"); | 2307 y<String>("hello"); |
2259 } | 2308 } |
(...skipping 4108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6368 await computeAnalysisResult(source); | 6417 await computeAnalysisResult(source); |
6369 assertNoErrors(source); | 6418 assertNoErrors(source); |
6370 verify([source]); | 6419 verify([source]); |
6371 reset(); | 6420 reset(); |
6372 } | 6421 } |
6373 | 6422 |
6374 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { | 6423 Future<Null> _check_wrongNumberOfParametersForOperator1(String name) async { |
6375 await _check_wrongNumberOfParametersForOperator(name, "a"); | 6424 await _check_wrongNumberOfParametersForOperator(name, "a"); |
6376 } | 6425 } |
6377 } | 6426 } |
OLD | NEW |