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

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

Issue 2482573002: fix #27764, split STATIC_TYPE_ERROR into more detailed ones (Closed)
Patch Set: format Created 4 years, 1 month 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
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 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 checkFile(r''' 716 checkFile(r'''
717 class Animal { 717 class Animal {
718 Animal(); 718 Animal();
719 factory Animal.cat() => new Cat(); 719 factory Animal.cat() => new Cat();
720 } 720 }
721 721
722 class Cat extends Animal {} 722 class Cat extends Animal {}
723 723
724 void main() { 724 void main() {
725 Cat c = /*info:ASSIGNMENT_CAST*/new Animal.cat(); 725 Cat c = /*info:ASSIGNMENT_CAST*/new Animal.cat();
726 c = /*error:STATIC_TYPE_ERROR*/new Animal(); 726 c = /*error:INVALID_CAST_NEW_EXPR*/new Animal();
727 }'''); 727 }''');
728 } 728 }
729 729
730 void test_fieldFieldOverride() { 730 void test_fieldFieldOverride() {
731 checkFile(''' 731 checkFile('''
732 class A {} 732 class A {}
733 class B extends A {} 733 class B extends A {}
734 class C extends B {} 734 class C extends B {}
735 735
736 class Base { 736 class Base {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 1035 }
1036 { 1036 {
1037 Top f; 1037 Top f;
1038 f = top; 1038 f = top;
1039 f = left; 1039 f = left;
1040 f = right; 1040 f = right;
1041 f = bot; 1041 f = bot;
1042 } 1042 }
1043 { 1043 {
1044 Left f; 1044 Left f;
1045 f = /*error:STATIC_TYPE_ERROR*/top; 1045 f = /*error:INVALID_CAST_FUNCTION*/top;
1046 f = left; 1046 f = left;
1047 f = /*error:INVALID_ASSIGNMENT*/right; 1047 f = /*error:INVALID_ASSIGNMENT*/right;
1048 f = bot; 1048 f = bot;
1049 } 1049 }
1050 { 1050 {
1051 Right f; 1051 Right f;
1052 f = /*error:STATIC_TYPE_ERROR*/top; 1052 f = /*error:INVALID_CAST_FUNCTION*/top;
1053 f = /*error:INVALID_ASSIGNMENT*/left; 1053 f = /*error:INVALID_ASSIGNMENT*/left;
1054 f = right; 1054 f = right;
1055 f = bot; 1055 f = bot;
1056 } 1056 }
1057 { 1057 {
1058 Bot f; 1058 Bot f;
1059 f = /*error:STATIC_TYPE_ERROR*/top; 1059 f = /*error:INVALID_CAST_FUNCTION*/top;
1060 f = /*error:STATIC_TYPE_ERROR*/left; 1060 f = /*error:INVALID_CAST_FUNCTION*/left;
1061 f = /*error:STATIC_TYPE_ERROR*/right; 1061 f = /*error:INVALID_CAST_FUNCTION*/right;
1062 f = bot; 1062 f = bot;
1063 } 1063 }
1064 } 1064 }
1065 '''); 1065 ''');
1066 } 1066 }
1067 1067
1068 void test_functionTypingAndSubtyping_dynamic() { 1068 void test_functionTypingAndSubtyping_dynamic() {
1069 checkFile(''' 1069 checkFile('''
1070 class A {} 1070 class A {}
1071 1071
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (/*info:UNNECESSARY_CAST* /x as Object), 1219 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (/*info:UNNECESSARY_CAST* /x as Object),
1220 botA, 1220 botA,
1221 /*warning:DOWN_CAST_COMPOSITE*/botTop 1221 /*warning:DOWN_CAST_COMPOSITE*/botTop
1222 ); 1222 );
1223 } 1223 }
1224 { 1224 {
1225 AA f; 1225 AA f;
1226 f = topA; 1226 f = topA;
1227 f = /*error:INVALID_ASSIGNMENT*/topTop; 1227 f = /*error:INVALID_ASSIGNMENT*/topTop;
1228 f = aa; 1228 f = aa;
1229 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 1229 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1230 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 1230 f = /*warning:DOWN_CAST_COMPOSITE*/botA;
1231 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1231 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
1232 apply/*<AA>*/( 1232 apply/*<AA>*/(
1233 topA, 1233 topA,
1234 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop, 1234 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop,
1235 aa, 1235 aa,
1236 /*error:STATIC_TYPE_ERROR*/aTop, // known function 1236 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1237 /*warning:DOWN_CAST_COMPOSITE*/botA, 1237 /*warning:DOWN_CAST_COMPOSITE*/botA,
1238 /*warning:DOWN_CAST_COMPOSITE*/botTop 1238 /*warning:DOWN_CAST_COMPOSITE*/botTop
1239 ); 1239 );
1240 apply/*<AA>*/( 1240 apply/*<AA>*/(
1241 (dynamic x) => new A(), 1241 (dynamic x) => new A(),
1242 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object), 1242 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object),
1243 (A x) => x, 1243 (A x) => x,
1244 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // known function 1244 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1245 /*warning:DOWN_CAST_COMPOSITE*/botA, 1245 /*warning:DOWN_CAST_COMPOSITE*/botA,
1246 /*warning:DOWN_CAST_COMPOSITE*/botTop 1246 /*warning:DOWN_CAST_COMPOSITE*/botTop
1247 ); 1247 );
1248 } 1248 }
1249 { 1249 {
1250 TopTop f; 1250 TopTop f;
1251 f = topA; 1251 f = topA;
1252 f = topTop; 1252 f = topTop;
1253 f = /*error:INVALID_ASSIGNMENT*/aa; 1253 f = /*error:INVALID_ASSIGNMENT*/aa;
1254 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 1254 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1255 f = /*error:INVALID_ASSIGNMENT*/botA; 1255 f = /*error:INVALID_ASSIGNMENT*/botA;
1256 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1256 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
1257 apply/*<TopTop>*/( 1257 apply/*<TopTop>*/(
1258 topA, 1258 topA,
1259 topTop, 1259 topTop,
1260 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa, 1260 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa,
1261 /*error:STATIC_TYPE_ERROR*/aTop, // known function 1261 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1262 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1262 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1263 /*warning:DOWN_CAST_COMPOSITE*/botTop 1263 /*warning:DOWN_CAST_COMPOSITE*/botTop
1264 ); 1264 );
1265 apply/*<TopTop>*/( 1265 apply/*<TopTop>*/(
1266 (dynamic x) => new A(), 1266 (dynamic x) => new A(),
1267 (dynamic x) => (x as Object), 1267 (dynamic x) => (x as Object),
1268 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x, 1268 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x,
1269 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // known function 1269 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1270 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1270 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1271 /*warning:DOWN_CAST_COMPOSITE*/botTop 1271 /*warning:DOWN_CAST_COMPOSITE*/botTop
1272 ); 1272 );
1273 } 1273 }
1274 { 1274 {
1275 TopA f; 1275 TopA f;
1276 f = topA; 1276 f = topA;
1277 f = /*error:STATIC_TYPE_ERROR*/topTop; // known function 1277 f = /*error:INVALID_CAST_FUNCTION*/topTop; // known function
1278 f = /*error:STATIC_TYPE_ERROR*/aa; // known function 1278 f = /*error:INVALID_CAST_FUNCTION*/aa; // known function
1279 f = /*error:STATIC_TYPE_ERROR*/aTop; // known function 1279 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1280 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 1280 f = /*warning:DOWN_CAST_COMPOSITE*/botA;
1281 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1281 f = /*warning:DOWN_CAST_COMPOSITE*/botTop;
1282 apply/*<TopA>*/( 1282 apply/*<TopA>*/(
1283 topA, 1283 topA,
1284 /*error:STATIC_TYPE_ERROR*/topTop, // known function 1284 /*error:INVALID_CAST_FUNCTION*/topTop, // known function
1285 /*error:STATIC_TYPE_ERROR*/aa, // known function 1285 /*error:INVALID_CAST_FUNCTION*/aa, // known function
1286 /*error:STATIC_TYPE_ERROR*/aTop, // known function 1286 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1287 /*warning:DOWN_CAST_COMPOSITE*/botA, 1287 /*warning:DOWN_CAST_COMPOSITE*/botA,
1288 /*warning:DOWN_CAST_COMPOSITE*/botTop 1288 /*warning:DOWN_CAST_COMPOSITE*/botTop
1289 ); 1289 );
1290 apply/*<TopA>*/( 1290 apply/*<TopA>*/(
1291 (dynamic x) => new A(), 1291 (dynamic x) => new A(),
1292 /*error:STATIC_TYPE_ERROR*/(dynamic x) => (x as Object), // known functi on 1292 /*error:INVALID_CAST_FUNCTION_EXPR*/(dynamic x) => (x as Object), // kno wn function
1293 /*error:STATIC_TYPE_ERROR*/(A x) => x, // known function 1293 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => x, // known function
1294 /*error:STATIC_TYPE_ERROR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Objec t), // 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_clasuresAreNotFuzzy() { 1303 void test_functionTypingAndSubtyping_dynamicFunctions_closuresAreNotFuzzy() {
1304 // Regression test for 1304 // Regression test for
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 checkFile(''' 1307 checkFile('''
1308 void takesF(void f(int x)) {} 1308 void takesF(void f(int x)) {}
1309 1309
1310 typedef void TakesInt(int x); 1310 typedef void TakesInt(int x);
1311 1311
1312 void update(_) {} 1312 void update(_) {}
1313 void updateOpt([_]) {} 1313 void updateOpt([_]) {}
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 void main() { 1372 void main() {
1373 { 1373 {
1374 Function2<B, A> f; 1374 Function2<B, A> f;
1375 f = top; 1375 f = top;
1376 f = left; 1376 f = left;
1377 f = right; 1377 f = right;
1378 f = bot; 1378 f = bot;
1379 } 1379 }
1380 { 1380 {
1381 Function2<B, B> f; // left 1381 Function2<B, B> f; // left
1382 f = /*error:STATIC_TYPE_ERROR*/top; 1382 f = /*error:INVALID_CAST_FUNCTION*/top;
1383 f = left; 1383 f = left;
1384 f = /*error:INVALID_ASSIGNMENT*/right; 1384 f = /*error:INVALID_ASSIGNMENT*/right;
1385 f = bot; 1385 f = bot;
1386 } 1386 }
1387 { 1387 {
1388 Function2<A, A> f; // right 1388 Function2<A, A> f; // right
1389 f = /*error:STATIC_TYPE_ERROR*/top; 1389 f = /*error:INVALID_CAST_FUNCTION*/top;
1390 f = /*error:INVALID_ASSIGNMENT*/left; 1390 f = /*error:INVALID_ASSIGNMENT*/left;
1391 f = right; 1391 f = right;
1392 f = bot; 1392 f = bot;
1393 } 1393 }
1394 { 1394 {
1395 Function2<A, B> f; 1395 Function2<A, B> f;
1396 f = /*error:STATIC_TYPE_ERROR*/top; 1396 f = /*error:INVALID_CAST_FUNCTION*/top;
1397 f = /*error:STATIC_TYPE_ERROR*/left; 1397 f = /*error:INVALID_CAST_FUNCTION*/left;
1398 f = /*error:STATIC_TYPE_ERROR*/right; 1398 f = /*error:INVALID_CAST_FUNCTION*/right;
1399 f = bot; 1399 f = bot;
1400 } 1400 }
1401 } 1401 }
1402 '''); 1402 ''');
1403 } 1403 }
1404 1404
1405 void test_functionTypingAndSubtyping_functionVariableVariance() { 1405 void test_functionTypingAndSubtyping_functionVariableVariance() {
1406 checkFile(''' 1406 checkFile('''
1407 class A {} 1407 class A {}
1408 class B extends A {} 1408 class B extends A {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 void main() { 1459 void main() {
1460 { 1460 {
1461 Function2<AToB, BToA> f; // Top 1461 Function2<AToB, BToA> f; // Top
1462 f = top; 1462 f = top;
1463 f = left; 1463 f = left;
1464 f = right; 1464 f = right;
1465 f = bot; 1465 f = bot;
1466 } 1466 }
1467 { 1467 {
1468 Function2<AToB, AToB> f; // Left 1468 Function2<AToB, AToB> f; // Left
1469 f = /*error:STATIC_TYPE_ERROR*/top; 1469 f = /*error:INVALID_CAST_FUNCTION*/top;
1470 f = left; 1470 f = left;
1471 f = /*error:INVALID_ASSIGNMENT*/right; 1471 f = /*error:INVALID_ASSIGNMENT*/right;
1472 f = bot; 1472 f = bot;
1473 } 1473 }
1474 { 1474 {
1475 Function2<BToA, BToA> f; // Right 1475 Function2<BToA, BToA> f; // Right
1476 f = /*error:STATIC_TYPE_ERROR*/top; 1476 f = /*error:INVALID_CAST_FUNCTION*/top;
1477 f = /*error:INVALID_ASSIGNMENT*/left; 1477 f = /*error:INVALID_ASSIGNMENT*/left;
1478 f = right; 1478 f = right;
1479 f = bot; 1479 f = bot;
1480 } 1480 }
1481 { 1481 {
1482 Function2<BToA, AToB> f; // Bot 1482 Function2<BToA, AToB> f; // Bot
1483 f = bot; 1483 f = bot;
1484 f = /*error:STATIC_TYPE_ERROR*/left; 1484 f = /*error:INVALID_CAST_FUNCTION*/left;
1485 f = /*error:STATIC_TYPE_ERROR*/top; 1485 f = /*error:INVALID_CAST_FUNCTION*/top;
1486 f = /*error:STATIC_TYPE_ERROR*/right; 1486 f = /*error:INVALID_CAST_FUNCTION*/right;
1487 } 1487 }
1488 } 1488 }
1489 '''); 1489 ''');
1490 } 1490 }
1491 1491
1492 void test_functionTypingAndSubtyping_higherOrderFunctionLiteral2() { 1492 void test_functionTypingAndSubtyping_higherOrderFunctionLiteral2() {
1493 checkFile(''' 1493 checkFile('''
1494 class A {} 1494 class A {}
1495 class B extends A {} 1495 class B extends A {}
1496 1496
(...skipping 11 matching lines...) Expand all
1508 void main() { 1508 void main() {
1509 { 1509 {
1510 Function2<AToB, BToA> f; // Top 1510 Function2<AToB, BToA> f; // Top
1511 f = top; 1511 f = top;
1512 f = left; 1512 f = left;
1513 f = right; 1513 f = right;
1514 f = bot; 1514 f = bot;
1515 } 1515 }
1516 { 1516 {
1517 Function2<AToB, AToB> f; // Left 1517 Function2<AToB, AToB> f; // Left
1518 f = /*error:STATIC_TYPE_ERROR*/top; 1518 f = /*error:INVALID_CAST_FUNCTION*/top;
1519 f = left; 1519 f = left;
1520 f = /*error:INVALID_ASSIGNMENT*/right; 1520 f = /*error:INVALID_ASSIGNMENT*/right;
1521 f = bot; 1521 f = bot;
1522 } 1522 }
1523 { 1523 {
1524 Function2<BToA, BToA> f; // Right 1524 Function2<BToA, BToA> f; // Right
1525 f = /*error:STATIC_TYPE_ERROR*/top; 1525 f = /*error:INVALID_CAST_FUNCTION*/top;
1526 f = /*error:INVALID_ASSIGNMENT*/left; 1526 f = /*error:INVALID_ASSIGNMENT*/left;
1527 f = right; 1527 f = right;
1528 f = bot; 1528 f = bot;
1529 } 1529 }
1530 { 1530 {
1531 Function2<BToA, AToB> f; // Bot 1531 Function2<BToA, AToB> f; // Bot
1532 f = bot; 1532 f = bot;
1533 f = /*error:STATIC_TYPE_ERROR*/left; 1533 f = /*error:INVALID_CAST_FUNCTION*/left;
1534 f = /*error:STATIC_TYPE_ERROR*/top; 1534 f = /*error:INVALID_CAST_FUNCTION*/top;
1535 f = /*error:STATIC_TYPE_ERROR*/right; 1535 f = /*error:INVALID_CAST_FUNCTION*/right;
1536 } 1536 }
1537 } 1537 }
1538 '''); 1538 ''');
1539 } 1539 }
1540 1540
1541 void test_functionTypingAndSubtyping_higherOrderFunctionLiteral3() { 1541 void test_functionTypingAndSubtyping_higherOrderFunctionLiteral3() {
1542 checkFile(''' 1542 checkFile('''
1543 class A {} 1543 class A {}
1544 class B extends A {} 1544 class B extends A {}
1545 1545
(...skipping 11 matching lines...) Expand all
1557 void main() { 1557 void main() {
1558 { 1558 {
1559 Function2<AToB, BToA> f; // Top 1559 Function2<AToB, BToA> f; // Top
1560 f = top; 1560 f = top;
1561 f = left; 1561 f = left;
1562 f = right; 1562 f = right;
1563 f = bot; 1563 f = bot;
1564 } 1564 }
1565 { 1565 {
1566 Function2<AToB, AToB> f; // Left 1566 Function2<AToB, AToB> f; // Left
1567 f = /*error:STATIC_TYPE_ERROR*/top; 1567 f = /*error:INVALID_CAST_FUNCTION*/top;
1568 f = left; 1568 f = left;
1569 f = /*error:INVALID_ASSIGNMENT*/right; 1569 f = /*error:INVALID_ASSIGNMENT*/right;
1570 f = bot; 1570 f = bot;
1571 } 1571 }
1572 { 1572 {
1573 Function2<BToA, BToA> f; // Right 1573 Function2<BToA, BToA> f; // Right
1574 f = /*error:STATIC_TYPE_ERROR*/top; 1574 f = /*error:INVALID_CAST_FUNCTION*/top;
1575 f = /*error:INVALID_ASSIGNMENT*/left; 1575 f = /*error:INVALID_ASSIGNMENT*/left;
1576 f = right; 1576 f = right;
1577 f = bot; 1577 f = bot;
1578 } 1578 }
1579 { 1579 {
1580 Function2<BToA, AToB> f; // Bot 1580 Function2<BToA, AToB> f; // Bot
1581 f = bot; 1581 f = bot;
1582 f = /*error:STATIC_TYPE_ERROR*/left; 1582 f = /*error:INVALID_CAST_FUNCTION*/left;
1583 f = /*error:STATIC_TYPE_ERROR*/top; 1583 f = /*error:INVALID_CAST_FUNCTION*/top;
1584 f = /*error:STATIC_TYPE_ERROR*/right; 1584 f = /*error:INVALID_CAST_FUNCTION*/right;
1585 } 1585 }
1586 } 1586 }
1587 '''); 1587 ''');
1588 } 1588 }
1589 1589
1590 void test_functionTypingAndSubtyping_higherOrderFunctionVariables() { 1590 void test_functionTypingAndSubtyping_higherOrderFunctionVariables() {
1591 checkFile(''' 1591 checkFile('''
1592 class A {} 1592 class A {}
1593 class B extends A {} 1593 class B extends A {}
1594 1594
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 void main() { 1930 void main() {
1931 { 1931 {
1932 Function2<B, A> f; 1932 Function2<B, A> f;
1933 f = C.top; 1933 f = C.top;
1934 f = C.left; 1934 f = C.left;
1935 f = C.right; 1935 f = C.right;
1936 f = C.bot; 1936 f = C.bot;
1937 } 1937 }
1938 { 1938 {
1939 Function2<B, B> f; 1939 Function2<B, B> f;
1940 f = /*error:STATIC_TYPE_ERROR*/C.top; 1940 f = /*error:INVALID_CAST_METHOD*/C.top;
1941 f = C.left; 1941 f = C.left;
1942 f = /*error:INVALID_ASSIGNMENT*/C.right; 1942 f = /*error:INVALID_ASSIGNMENT*/C.right;
1943 f = C.bot; 1943 f = C.bot;
1944 } 1944 }
1945 { 1945 {
1946 Function2<A, A> f; 1946 Function2<A, A> f;
1947 f = /*error:STATIC_TYPE_ERROR*/C.top; 1947 f = /*error:INVALID_CAST_METHOD*/C.top;
1948 f = /*error:INVALID_ASSIGNMENT*/C.left; 1948 f = /*error:INVALID_ASSIGNMENT*/C.left;
1949 f = C.right; 1949 f = C.right;
1950 f = C.bot; 1950 f = C.bot;
1951 } 1951 }
1952 { 1952 {
1953 Function2<A, B> f; 1953 Function2<A, B> f;
1954 f = /*error:STATIC_TYPE_ERROR*/C.top; 1954 f = /*error:INVALID_CAST_METHOD*/C.top;
1955 f = /*error:STATIC_TYPE_ERROR*/C.left; 1955 f = /*error:INVALID_CAST_METHOD*/C.left;
1956 f = /*error:STATIC_TYPE_ERROR*/C.right; 1956 f = /*error:INVALID_CAST_METHOD*/C.right;
1957 f = C.bot; 1957 f = C.bot;
1958 } 1958 }
1959 } 1959 }
1960 '''); 1960 ''');
1961 } 1961 }
1962 1962
1963 void test_functionTypingAndSubtyping_subtypeOfUniversalType() { 1963 void test_functionTypingAndSubtyping_subtypeOfUniversalType() {
1964 checkFile(''' 1964 checkFile('''
1965 void main() { 1965 void main() {
1966 nonGenericFn(x) => null; 1966 nonGenericFn(x) => null;
(...skipping 10 matching lines...) Expand all
1977 } 1977 }
1978 { 1978 {
1979 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null; 1979 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null;
1980 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null; 1980 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null;
1981 1981
1982 var local = f; 1982 var local = f;
1983 local = g; // valid 1983 local = g; // valid
1984 1984
1985 var local2 = g; 1985 var local2 = g;
1986 local = local2; 1986 local = local2;
1987 local2 = /*error:STATIC_TYPE_ERROR*/f; 1987 local2 = /*error:INVALID_CAST_FUNCTION*/f;
1988 local2 = /*warning:DOWN_CAST_COMPOSITE*/local; 1988 local2 = /*warning:DOWN_CAST_COMPOSITE*/local;
1989 1989
1990 // Non-generic function cannot subtype a generic one. 1990 // Non-generic function cannot subtype a generic one.
1991 local = /*error:INVALID_ASSIGNMENT*/(x) => null; 1991 local = /*error:INVALID_ASSIGNMENT*/(x) => null;
1992 local = /*error:INVALID_ASSIGNMENT*/nonGenericFn; 1992 local = /*error:INVALID_ASSIGNMENT*/nonGenericFn;
1993 } 1993 }
1994 } 1994 }
1995 '''); 1995 ''');
1996 } 1996 }
1997 1997
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3995 // Regression test for https://github.com/dart-lang/sdk/issues/25069 3995 // Regression test for https://github.com/dart-lang/sdk/issues/25069
3996 checkFile(''' 3996 checkFile('''
3997 typedef int Foo(); 3997 typedef int Foo();
3998 void foo() {} 3998 void foo() {}
3999 void main () { 3999 void main () {
4000 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo(); 4000 Foo x = /*error:INVALID_ASSIGNMENT,info:USE_OF_VOID_RESULT*/foo();
4001 } 4001 }
4002 '''); 4002 ''');
4003 } 4003 }
4004 } 4004 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698