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

Side by Side Diff: pkg/analyzer/test/generated/strong_mode_test.dart

Issue 2752423003: Restore weak mode errors on empty returns in Null functions (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « pkg/analyzer/test/generated/static_warning_code_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 '''); 1136 ''');
1137 _isFunction2Of(_isInt, _isNull)( 1137 _isFunction2Of(_isInt, _isNull)(
1138 invoke.argumentList.arguments[0].staticType); 1138 invoke.argumentList.arguments[0].staticType);
1139 _isFutureOfDynamic(invoke.staticType); 1139 _isFutureOfDynamic(invoke.staticType);
1140 } 1140 }
1141 1141
1142 test_futureOr_return_null() async { 1142 test_futureOr_return_null() async {
1143 MethodInvocation invoke = await _testFutureOr(r''' 1143 MethodInvocation invoke = await _testFutureOr(r'''
1144 FutureOr<T> mk<T>(Future<T> x) => x; 1144 FutureOr<T> mk<T>(Future<T> x) => x;
1145 Future<int> f; 1145 Future<int> f;
1146 test() => f.then((int x) {}); 1146 test() => f.then((int x) {return null;});
1147 '''); 1147 ''');
1148 _isFunction2Of(_isInt, _isNull)( 1148 _isFunction2Of(_isInt, _isNull)(
1149 invoke.argumentList.arguments[0].staticType); 1149 invoke.argumentList.arguments[0].staticType);
1150 _isFutureOfDynamic(invoke.staticType); 1150 _isFutureOfDynamic(invoke.staticType);
1151 } 1151 }
1152 1152
1153 test_futureOr_upwards1() async { 1153 test_futureOr_upwards1() async {
1154 // Test that upwards inference correctly prefers to instantiate type 1154 // Test that upwards inference correctly prefers to instantiate type
1155 // variables with the "smaller" solution when both are possible. 1155 // variables with the "smaller" solution when both are possible.
1156 MethodInvocation invoke = await _testFutureOr(r''' 1156 MethodInvocation invoke = await _testFutureOr(r'''
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 '''); 1191 ''');
1192 _isFunction2Of(_isInt, _isNull)( 1192 _isFunction2Of(_isInt, _isNull)(
1193 invoke.argumentList.arguments[0].staticType); 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) { return null;});
1202 '''); 1202 ''');
1203 _isFunction2Of(_isInt, _isNull)( 1203 _isFunction2Of(_isInt, _isNull)(
1204 invoke.argumentList.arguments[0].staticType); 1204 invoke.argumentList.arguments[0].staticType);
1205 _isFutureOfNull(invoke.staticType); 1205 _isFutureOfNull(invoke.staticType);
1206 } 1206 }
1207 1207
1208 test_inference_hints() async { 1208 test_inference_hints() async {
1209 Source source = addSource(r''' 1209 Source source = addSource(r'''
1210 void main () { 1210 void main () {
1211 var x = 3; 1211 var x = 3;
(...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 var v = x; 3555 var v = x;
3556 v; // marker 3556 v; // marker
3557 } 3557 }
3558 int x = 3; 3558 int x = 3;
3559 '''; 3559 ''';
3560 CompilationUnit unit = await resolveSource(code); 3560 CompilationUnit unit = await resolveSource(code);
3561 assertPropagatedAssignedType(code, unit, typeProvider.intType, null); 3561 assertPropagatedAssignedType(code, unit, typeProvider.intType, null);
3562 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null); 3562 assertTypeOfMarkedExpression(code, unit, typeProvider.intType, null);
3563 } 3563 }
3564 } 3564 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/static_warning_code_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698