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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2594873002: Make call methods definite. (Closed)
Patch Set: Rebase Created 3 years, 11 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/lib/src/task/strong/checker.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.src.task.strong.checker_test; 5 library analyzer.test.src.task.strong.checker_test;
6 6
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; 7 import 'package:test_reflective_loader/test_reflective_loader.dart';
8 8
9 import 'strong_test_helper.dart'; 9 import 'strong_test_helper.dart';
10 10
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function 1294 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1295 /*warning:DOWN_CAST_COMPOSITE*/botA, 1295 /*warning:DOWN_CAST_COMPOSITE*/botA,
1296 /*warning:DOWN_CAST_COMPOSITE*/botTop 1296 /*warning:DOWN_CAST_COMPOSITE*/botTop
1297 ); 1297 );
1298 } 1298 }
1299 } 1299 }
1300 '''); 1300 ''');
1301 } 1301 }
1302 1302
1303 void test_functionTypingAndSubtyping_dynamicFunctions_closuresAreNotFuzzy() { 1303 void test_functionTypingAndSubtyping_dynamicFunctions_closuresAreNotFuzzy() {
1304 // Regression test for 1304 // Regression test for definite function cases
1305 // https://github.com/dart-lang/sdk/issues/26118 1305 // https://github.com/dart-lang/sdk/issues/26118
1306 // https://github.com/dart-lang/sdk/issues/26156 1306 // https://github.com/dart-lang/sdk/issues/26156
1307 // https://github.com/dart-lang/sdk/issues/28087
1307 checkFile(''' 1308 checkFile('''
1308 void takesF(void f(int x)) {} 1309 void takesF(void f(int x)) {}
1309 1310
1310 typedef void TakesInt(int x); 1311 typedef void TakesInt(int x);
1311 1312
1312 void update(_) {} 1313 void update(_) {}
1313 void updateOpt([_]) {} 1314 void updateOpt([_]) {}
1314 void updateOptNum([num x]) {} 1315 void updateOptNum([num x]) {}
1315 1316
1317 class Callable {
1318 void call(_) {}
1319 }
1320
1316 class A { 1321 class A {
1317 TakesInt f; 1322 TakesInt f;
1318 A(TakesInt g) { 1323 A(TakesInt g) {
1319 f = update; 1324 f = update;
1320 f = updateOpt; 1325 f = updateOpt;
1321 f = updateOptNum; 1326 f = updateOptNum;
1327 f = new Callable();
1322 } 1328 }
1323 TakesInt g(bool a, bool b) { 1329 TakesInt g(bool a, bool b) {
1324 if (a) { 1330 if (a) {
1325 return update; 1331 return update;
1326 } else if (b) { 1332 } else if (b) {
1327 return updateOpt; 1333 return updateOpt;
1334 } else if (a) {
1335 return updateOptNum;
1328 } else { 1336 } else {
1329 return updateOptNum; 1337 return new Callable();
1330 } 1338 }
1331 } 1339 }
1332 } 1340 }
1333 1341
1334 void test0() { 1342 void test0() {
1335 takesF(update); 1343 takesF(update);
1336 takesF(updateOpt); 1344 takesF(updateOpt);
1337 takesF(updateOptNum); 1345 takesF(updateOptNum);
1346 takesF(new Callable());
1338 TakesInt f; 1347 TakesInt f;
1339 f = update; 1348 f = update;
1340 f = updateOpt; 1349 f = updateOpt;
1341 f = updateOptNum; 1350 f = updateOptNum;
1351 f = new Callable();
1342 new A(update); 1352 new A(update);
1343 new A(updateOpt); 1353 new A(updateOpt);
1344 new A(updateOptNum); 1354 new A(updateOptNum);
1355 new A(new Callable());
1345 } 1356 }
1346 1357
1347 void test1() { 1358 void test1() {
1348 void takesF(f(int x)) => null; 1359 void takesF(f(int x)) => null;
1349 takesF((dynamic y) => 3); 1360 takesF((dynamic y) => 3);
1350 } 1361 }
1351 1362
1352 void test2() { 1363 void test2() {
1353 int x; 1364 int x;
1354 int f/*<T>*/(/*=T*/ t, callback(/*=T*/ x)) { return 3; } 1365 int f/*<T>*/(/*=T*/ t, callback(/*=T*/ x)) { return 3; }
(...skipping 2661 matching lines...) Expand 10 before | Expand all | Expand 10 after
4016 // Regression test for https://github.com/dart-lang/sdk/issues/25069 4027 // Regression test for https://github.com/dart-lang/sdk/issues/25069
4017 checkFile(''' 4028 checkFile('''
4018 typedef int Foo(); 4029 typedef int Foo();
4019 void foo() {} 4030 void foo() {}
4020 void main () { 4031 void main () {
4021 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 4032 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
4022 } 4033 }
4023 '''); 4034 ''');
4024 } 4035 }
4025 } 4036 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698