| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_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 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 // match the bound. | 1165 // match the bound. |
| 1166 MethodInvocation invoke = await _testFutureOr( | 1166 MethodInvocation invoke = await _testFutureOr( |
| 1167 r''' | 1167 r''' |
| 1168 Future<T> mk<T extends Future<Object>>(FutureOr<T> x) => null; | 1168 Future<T> mk<T extends Future<Object>>(FutureOr<T> x) => null; |
| 1169 dynamic test() => mk(new Future<int>.value(42)); | 1169 dynamic test() => mk(new Future<int>.value(42)); |
| 1170 ''', | 1170 ''', |
| 1171 errors: [StrongModeCode.COULD_NOT_INFER]); | 1171 errors: [StrongModeCode.COULD_NOT_INFER]); |
| 1172 _isFutureOf([_isObject])(invoke.staticType); | 1172 _isFutureOf([_isObject])(invoke.staticType); |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 test_futureOrNull_no_return() async { |
| 1176 MethodInvocation invoke = await _testFutureOr(r''' |
| 1177 FutureOr<T> mk<T>(Future<T> x) => x; |
| 1178 Future<int> f; |
| 1179 test() => f.then<Null>((int x) {}); |
| 1180 '''); |
| 1181 _isFunction2Of(_isInt, _isNull)( |
| 1182 invoke.argumentList.arguments[0].staticType); |
| 1183 _isFutureOfNull(invoke.staticType); |
| 1184 } |
| 1185 |
| 1175 test_futureOrNull_no_return_value() async { | 1186 test_futureOrNull_no_return_value() async { |
| 1176 MethodInvocation invoke = await _testFutureOr(r''' | 1187 MethodInvocation invoke = await _testFutureOr(r''' |
| 1177 FutureOr<T> mk<T>(Future<T> x) => x; | 1188 FutureOr<T> mk<T>(Future<T> x) => x; |
| 1178 Future<int> f; | 1189 Future<int> f; |
| 1179 test() => f.then<Null>((int x) {return;}); | 1190 test() => f.then<Null>((int x) {return;}); |
| 1180 '''); | 1191 '''); |
| 1181 _isFunction2Of(_isInt, _isNull)( | 1192 _isFunction2Of(_isInt, _isNull)( |
| 1182 invoke.argumentList.arguments[0].staticType); | 1193 invoke.argumentList.arguments[0].staticType); |
| 1183 _isFutureOfNull(invoke.staticType); | |
| 1184 } | |
| 1185 | |
| 1186 test_futureOrNull_no_return() async { | |
| 1187 MethodInvocation invoke = await _testFutureOr(r''' | |
| 1188 FutureOr<T> mk<T>(Future<T> x) => x; | |
| 1189 Future<int> f; | |
| 1190 test() => f.then<Null>((int x) {}); | |
| 1191 '''); | |
| 1192 _isFunction2Of(_isInt, _isNull)( | |
| 1193 invoke.argumentList.arguments[0].staticType); | |
| 1194 _isFutureOfNull(invoke.staticType); | 1194 _isFutureOfNull(invoke.staticType); |
| 1195 } | 1195 } |
| 1196 | 1196 |
| 1197 test_futureOrNull_return_null() async { | 1197 test_futureOrNull_return_null() async { |
| 1198 MethodInvocation invoke = await _testFutureOr(r''' | 1198 MethodInvocation invoke = await _testFutureOr(r''' |
| 1199 FutureOr<T> mk<T>(Future<T> x) => x; | 1199 FutureOr<T> mk<T>(Future<T> x) => x; |
| 1200 Future<int> f; | 1200 Future<int> f; |
| 1201 test() => f.then<Null>((int x) {}); | 1201 test() => f.then<Null>((int x) {}); |
| 1202 '''); | 1202 '''); |
| 1203 _isFunction2Of(_isInt, _isNull)( | 1203 _isFunction2Of(_isInt, _isNull)( |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 class B extends A {} | 2654 class B extends A {} |
| 2655 class C { | 2655 class C { |
| 2656 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null; | 2656 /*=T*/ f/*<T extends B>*/(/*=T*/ x) => null; |
| 2657 } | 2657 } |
| 2658 class D extends C { | 2658 class D extends C { |
| 2659 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null; | 2659 /*=T*/ f/*<T extends A>*/(/*=T*/ x) => null; |
| 2660 } | 2660 } |
| 2661 '''); | 2661 '''); |
| 2662 } | 2662 } |
| 2663 | 2663 |
| 2664 test_genericMethod_override_covariant_field() async { |
| 2665 Source source = addSource(r''' |
| 2666 abstract class A { |
| 2667 num get x; |
| 2668 set x(covariant num); |
| 2669 } |
| 2670 |
| 2671 class B extends A { |
| 2672 int x; |
| 2673 } |
| 2674 '''); |
| 2675 await computeAnalysisResult(source); |
| 2676 assertNoErrors(source); |
| 2677 verify([source]); |
| 2678 } |
| 2679 |
| 2664 test_genericMethod_override_invalidReturnType() async { | 2680 test_genericMethod_override_invalidReturnType() async { |
| 2665 Source source = addSource(r''' | 2681 Source source = addSource(r''' |
| 2666 class C { | 2682 class C { |
| 2667 Iterable/*<T>*/ f/*<T>*/(/*=T*/ x) => null; | 2683 Iterable/*<T>*/ f/*<T>*/(/*=T*/ x) => null; |
| 2668 } | 2684 } |
| 2669 class D extends C { | 2685 class D extends C { |
| 2670 String f/*<S>*/(/*=S*/ x) => null; | 2686 String f/*<S>*/(/*=S*/ x) => null; |
| 2671 }'''); | 2687 }'''); |
| 2672 await computeAnalysisResult(source); | 2688 await computeAnalysisResult(source); |
| 2673 assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]); | 2689 assertErrors(source, [StrongModeCode.INVALID_METHOD_OVERRIDE]); |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3539 var v = x; | 3555 var v = x; |
| 3540 v; // marker | 3556 v; // marker |
| 3541 } | 3557 } |
| 3542 int x = 3; | 3558 int x = 3; |
| 3543 '''; | 3559 '''; |
| 3544 CompilationUnit unit = await resolveSource(code); | 3560 CompilationUnit unit = await resolveSource(code); |
| 3545 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); | 3561 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); |
| 3546 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); | 3562 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); |
| 3547 } | 3563 } |
| 3548 } | 3564 } |
| OLD | NEW |