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

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

Issue 2738223002: Reland "Turn the DOWN_CAST_COMPOSITE strong mode error into a hint, which will" (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
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 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 Bottom bot; 1072 Bottom bot;
1073 { 1073 {
1074 Top f; 1074 Top f;
1075 f = top; 1075 f = top;
1076 f = left; 1076 f = left;
1077 f = right; 1077 f = right;
1078 f = bot; 1078 f = bot;
1079 } 1079 }
1080 { 1080 {
1081 Left f; 1081 Left f;
1082 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1082 f = /*info:DOWN_CAST_COMPOSITE*/top;
1083 f = left; 1083 f = left;
1084 f = /*error:INVALID_ASSIGNMENT*/right; 1084 f = /*error:INVALID_ASSIGNMENT*/right;
1085 f = bot; 1085 f = bot;
1086 } 1086 }
1087 { 1087 {
1088 Right f; 1088 Right f;
1089 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1089 f = /*info:DOWN_CAST_COMPOSITE*/top;
1090 f = /*error:INVALID_ASSIGNMENT*/left; 1090 f = /*error:INVALID_ASSIGNMENT*/left;
1091 f = right; 1091 f = right;
1092 f = bot; 1092 f = bot;
1093 } 1093 }
1094 { 1094 {
1095 Bottom f; 1095 Bottom f;
1096 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1096 f = /*info:DOWN_CAST_COMPOSITE*/top;
1097 f = /*warning:DOWN_CAST_COMPOSITE*/left; 1097 f = /*info:DOWN_CAST_COMPOSITE*/left;
1098 f = /*warning:DOWN_CAST_COMPOSITE*/right; 1098 f = /*info:DOWN_CAST_COMPOSITE*/right;
1099 f = bot; 1099 f = bot;
1100 } 1100 }
1101 } 1101 }
1102 '''); 1102 ''');
1103 } 1103 }
1104 1104
1105 test_functionTypingAndSubtyping_dynamic_knownFunctions() async { 1105 test_functionTypingAndSubtyping_dynamic_knownFunctions() async {
1106 // Our lattice should look like this: 1106 // Our lattice should look like this:
1107 // 1107 //
1108 // 1108 //
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 botTop 1162 botTop
1163 ); 1163 );
1164 } 1164 }
1165 { 1165 {
1166 ATop f; 1166 ATop f;
1167 f = topA; 1167 f = topA;
1168 f = topTop; 1168 f = topTop;
1169 f = aa; 1169 f = aa;
1170 f = aTop; 1170 f = aTop;
1171 f = /*error:INVALID_ASSIGNMENT*/botA; 1171 f = /*error:INVALID_ASSIGNMENT*/botA;
1172 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1172 f = /*info:DOWN_CAST_COMPOSITE*/botTop;
1173 apply/*<ATop>*/( 1173 apply/*<ATop>*/(
1174 topA, 1174 topA,
1175 topTop, 1175 topTop,
1176 aa, 1176 aa,
1177 aTop, 1177 aTop,
1178 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1178 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1179 /*warning:DOWN_CAST_COMPOSITE*/botTop 1179 /*info:DOWN_CAST_COMPOSITE*/botTop
1180 ); 1180 );
1181 apply/*<ATop>*/( 1181 apply/*<ATop>*/(
1182 (dynamic x) => new A(), 1182 (dynamic x) => new A(),
1183 (dynamic x) => (x as Object), 1183 (dynamic x) => (x as Object),
1184 (A x) => x, 1184 (A x) => x,
1185 (A x) => null, 1185 (A x) => null,
1186 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1186 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1187 /*warning:DOWN_CAST_COMPOSITE*/botTop 1187 /*info:DOWN_CAST_COMPOSITE*/botTop
1188 ); 1188 );
1189 } 1189 }
1190 { 1190 {
1191 BotA f; 1191 BotA f;
1192 f = topA; 1192 f = topA;
1193 f = /*error:INVALID_ASSIGNMENT*/topTop; 1193 f = /*error:INVALID_ASSIGNMENT*/topTop;
1194 f = aa; 1194 f = aa;
1195 f = /*error:INVALID_ASSIGNMENT*/aTop; 1195 f = /*error:INVALID_ASSIGNMENT*/aTop;
1196 f = botA; 1196 f = botA;
1197 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1197 f = /*info:DOWN_CAST_COMPOSITE*/botTop;
1198 apply/*<BotA>*/( 1198 apply/*<BotA>*/(
1199 topA, 1199 topA,
1200 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop, 1200 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop,
1201 aa, 1201 aa,
1202 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aTop, 1202 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aTop,
1203 botA, 1203 botA,
1204 /*warning:DOWN_CAST_COMPOSITE*/botTop 1204 /*info:DOWN_CAST_COMPOSITE*/botTop
1205 ); 1205 );
1206 apply/*<BotA>*/( 1206 apply/*<BotA>*/(
1207 (dynamic x) => new A(), 1207 (dynamic x) => new A(),
1208 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object), 1208 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object),
1209 (A x) => x, 1209 (A x) => x,
1210 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (/*info:UNNECESSARY_CAST* /x as Object), 1210 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => (/*info:UNNECESSARY_CAST* /x as Object),
1211 botA, 1211 botA,
1212 /*warning:DOWN_CAST_COMPOSITE*/botTop 1212 /*info:DOWN_CAST_COMPOSITE*/botTop
1213 ); 1213 );
1214 } 1214 }
1215 { 1215 {
1216 AA f; 1216 AA f;
1217 f = topA; 1217 f = topA;
1218 f = /*error:INVALID_ASSIGNMENT*/topTop; 1218 f = /*error:INVALID_ASSIGNMENT*/topTop;
1219 f = aa; 1219 f = aa;
1220 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function 1220 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1221 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 1221 f = /*info:DOWN_CAST_COMPOSITE*/botA;
1222 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1222 f = /*info:DOWN_CAST_COMPOSITE*/botTop;
1223 apply/*<AA>*/( 1223 apply/*<AA>*/(
1224 topA, 1224 topA,
1225 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop, 1225 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/topTop,
1226 aa, 1226 aa,
1227 /*error:INVALID_CAST_FUNCTION*/aTop, // known function 1227 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1228 /*warning:DOWN_CAST_COMPOSITE*/botA, 1228 /*info:DOWN_CAST_COMPOSITE*/botA,
1229 /*warning:DOWN_CAST_COMPOSITE*/botTop 1229 /*info:DOWN_CAST_COMPOSITE*/botTop
1230 ); 1230 );
1231 apply/*<AA>*/( 1231 apply/*<AA>*/(
1232 (dynamic x) => new A(), 1232 (dynamic x) => new A(),
1233 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object), 1233 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(dynamic x) => (x as Object),
1234 (A x) => x, 1234 (A x) => x,
1235 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function 1235 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1236 /*warning:DOWN_CAST_COMPOSITE*/botA, 1236 /*info:DOWN_CAST_COMPOSITE*/botA,
1237 /*warning:DOWN_CAST_COMPOSITE*/botTop 1237 /*info:DOWN_CAST_COMPOSITE*/botTop
1238 ); 1238 );
1239 } 1239 }
1240 { 1240 {
1241 TopTop f; 1241 TopTop f;
1242 f = topA; 1242 f = topA;
1243 f = topTop; 1243 f = topTop;
1244 f = /*error:INVALID_ASSIGNMENT*/aa; 1244 f = /*error:INVALID_ASSIGNMENT*/aa;
1245 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function 1245 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1246 f = /*error:INVALID_ASSIGNMENT*/botA; 1246 f = /*error:INVALID_ASSIGNMENT*/botA;
1247 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1247 f = /*info:DOWN_CAST_COMPOSITE*/botTop;
1248 apply/*<TopTop>*/( 1248 apply/*<TopTop>*/(
1249 topA, 1249 topA,
1250 topTop, 1250 topTop,
1251 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa, 1251 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/aa,
1252 /*error:INVALID_CAST_FUNCTION*/aTop, // known function 1252 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1253 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1253 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1254 /*warning:DOWN_CAST_COMPOSITE*/botTop 1254 /*info:DOWN_CAST_COMPOSITE*/botTop
1255 ); 1255 );
1256 apply/*<TopTop>*/( 1256 apply/*<TopTop>*/(
1257 (dynamic x) => new A(), 1257 (dynamic x) => new A(),
1258 (dynamic x) => (x as Object), 1258 (dynamic x) => (x as Object),
1259 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x, 1259 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/(A x) => x,
1260 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function 1260 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1261 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA, 1261 /*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/botA,
1262 /*warning:DOWN_CAST_COMPOSITE*/botTop 1262 /*info:DOWN_CAST_COMPOSITE*/botTop
1263 ); 1263 );
1264 } 1264 }
1265 { 1265 {
1266 TopA f; 1266 TopA f;
1267 f = topA; 1267 f = topA;
1268 f = /*error:INVALID_CAST_FUNCTION*/topTop; // known function 1268 f = /*error:INVALID_CAST_FUNCTION*/topTop; // known function
1269 f = /*error:INVALID_CAST_FUNCTION*/aa; // known function 1269 f = /*error:INVALID_CAST_FUNCTION*/aa; // known function
1270 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function 1270 f = /*error:INVALID_CAST_FUNCTION*/aTop; // known function
1271 f = /*warning:DOWN_CAST_COMPOSITE*/botA; 1271 f = /*info:DOWN_CAST_COMPOSITE*/botA;
1272 f = /*warning:DOWN_CAST_COMPOSITE*/botTop; 1272 f = /*info:DOWN_CAST_COMPOSITE*/botTop;
1273 apply/*<TopA>*/( 1273 apply/*<TopA>*/(
1274 topA, 1274 topA,
1275 /*error:INVALID_CAST_FUNCTION*/topTop, // known function 1275 /*error:INVALID_CAST_FUNCTION*/topTop, // known function
1276 /*error:INVALID_CAST_FUNCTION*/aa, // known function 1276 /*error:INVALID_CAST_FUNCTION*/aa, // known function
1277 /*error:INVALID_CAST_FUNCTION*/aTop, // known function 1277 /*error:INVALID_CAST_FUNCTION*/aTop, // known function
1278 /*warning:DOWN_CAST_COMPOSITE*/botA, 1278 /*info:DOWN_CAST_COMPOSITE*/botA,
1279 /*warning:DOWN_CAST_COMPOSITE*/botTop 1279 /*info:DOWN_CAST_COMPOSITE*/botTop
1280 ); 1280 );
1281 apply/*<TopA>*/( 1281 apply/*<TopA>*/(
1282 (dynamic x) => new A(), 1282 (dynamic x) => new A(),
1283 /*error:INVALID_CAST_FUNCTION_EXPR*/(dynamic x) => (x as Object), // kno wn function 1283 /*error:INVALID_CAST_FUNCTION_EXPR*/(dynamic x) => (x as Object), // kno wn function
1284 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => x, // known function 1284 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => x, // known function
1285 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function 1285 /*error:INVALID_CAST_FUNCTION_EXPR*/(A x) => (/*info:UNNECESSARY_CAST*/x as Object), // known function
1286 /*warning:DOWN_CAST_COMPOSITE*/botA, 1286 /*info:DOWN_CAST_COMPOSITE*/botA,
1287 /*warning:DOWN_CAST_COMPOSITE*/botTop 1287 /*info:DOWN_CAST_COMPOSITE*/botTop
1288 ); 1288 );
1289 } 1289 }
1290 } 1290 }
1291 '''); 1291 ''');
1292 } 1292 }
1293 1293
1294 test_functionTypingAndSubtyping_dynamicFunctions_closuresAreNotFuzzy() async { 1294 test_functionTypingAndSubtyping_dynamicFunctions_closuresAreNotFuzzy() async {
1295 // Regression test for definite function cases 1295 // Regression test for definite function cases
1296 // https://github.com/dart-lang/sdk/issues/26118 1296 // https://github.com/dart-lang/sdk/issues/26118
1297 // https://github.com/dart-lang/sdk/issues/26156 1297 // https://github.com/dart-lang/sdk/issues/26156
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 Function2<B, A> top; 1416 Function2<B, A> top;
1417 Function2<B, B> left; 1417 Function2<B, B> left;
1418 Function2<A, A> right; 1418 Function2<A, A> right;
1419 Function2<A, B> bot; 1419 Function2<A, B> bot;
1420 1420
1421 top = right; 1421 top = right;
1422 top = bot; 1422 top = bot;
1423 top = top; 1423 top = top;
1424 top = left; 1424 top = left;
1425 1425
1426 left = /*warning:DOWN_CAST_COMPOSITE*/top; 1426 left = /*info:DOWN_CAST_COMPOSITE*/top;
1427 left = left; 1427 left = left;
1428 left = /*error:INVALID_ASSIGNMENT*/right; 1428 left = /*error:INVALID_ASSIGNMENT*/right;
1429 left = bot; 1429 left = bot;
1430 1430
1431 right = /*warning:DOWN_CAST_COMPOSITE*/top; 1431 right = /*info:DOWN_CAST_COMPOSITE*/top;
1432 right = /*error:INVALID_ASSIGNMENT*/left; 1432 right = /*error:INVALID_ASSIGNMENT*/left;
1433 right = right; 1433 right = right;
1434 right = bot; 1434 right = bot;
1435 1435
1436 bot = /*warning:DOWN_CAST_COMPOSITE*/top; 1436 bot = /*info:DOWN_CAST_COMPOSITE*/top;
1437 bot = /*warning:DOWN_CAST_COMPOSITE*/left; 1437 bot = /*info:DOWN_CAST_COMPOSITE*/left;
1438 bot = /*warning:DOWN_CAST_COMPOSITE*/right; 1438 bot = /*info:DOWN_CAST_COMPOSITE*/right;
1439 bot = bot; 1439 bot = bot;
1440 } 1440 }
1441 } 1441 }
1442 '''); 1442 ''');
1443 } 1443 }
1444 1444
1445 test_functionTypingAndSubtyping_higherOrderFunctionLiteral1() async { 1445 test_functionTypingAndSubtyping_higherOrderFunctionLiteral1() async {
1446 await checkFile(''' 1446 await checkFile('''
1447 class A {} 1447 class A {}
1448 class B extends A {} 1448 class B extends A {}
1449 1449
1450 typedef T Function2<S, T>(S z); 1450 typedef T Function2<S, T>(S z);
1451 1451
1452 typedef A BToA(B x); // Top of the base lattice 1452 typedef A BToA(B x); // Top of the base lattice
1453 typedef B AToB(A x); // Bot of the base lattice 1453 typedef B AToB(A x); // Bot of the base lattice
1454 1454
1455 BToA top(AToB f) => f; 1455 BToA top(AToB f) => f;
1456 AToB left(AToB f) => f; 1456 AToB left(AToB f) => f;
1457 BToA right(BToA f) => f; 1457 BToA right(BToA f) => f;
1458 AToB bot_(BToA f) => /*warning:DOWN_CAST_COMPOSITE*/f; 1458 AToB bot_(BToA f) => /*info:DOWN_CAST_COMPOSITE*/f;
1459 AToB bot(BToA f) => f as AToB; 1459 AToB bot(BToA f) => f as AToB;
1460 1460
1461 void main() { 1461 void main() {
1462 { 1462 {
1463 Function2<AToB, BToA> f; // Top 1463 Function2<AToB, BToA> f; // Top
1464 f = top; 1464 f = top;
1465 f = left; 1465 f = left;
1466 f = right; 1466 f = right;
1467 f = bot; 1467 f = bot;
1468 } 1468 }
(...skipping 28 matching lines...) Expand all
1497 class B extends A {} 1497 class B extends A {}
1498 1498
1499 typedef T Function2<S, T>(S z); 1499 typedef T Function2<S, T>(S z);
1500 1500
1501 typedef A BToA(B x); // Top of the base lattice 1501 typedef A BToA(B x); // Top of the base lattice
1502 typedef B AToB(A x); // Bot of the base lattice 1502 typedef B AToB(A x); // Bot of the base lattice
1503 1503
1504 Function2<B, A> top(AToB f) => f; 1504 Function2<B, A> top(AToB f) => f;
1505 Function2<A, B> left(AToB f) => f; 1505 Function2<A, B> left(AToB f) => f;
1506 Function2<B, A> right(BToA f) => f; 1506 Function2<B, A> right(BToA f) => f;
1507 Function2<A, B> bot_(BToA f) => /*warning:DOWN_CAST_COMPOSITE*/f; 1507 Function2<A, B> bot_(BToA f) => /*info:DOWN_CAST_COMPOSITE*/f;
1508 Function2<A, B> bot(BToA f) => f as Function2<A, B>; 1508 Function2<A, B> bot(BToA f) => f as Function2<A, B>;
1509 1509
1510 void main() { 1510 void main() {
1511 { 1511 {
1512 Function2<AToB, BToA> f; // Top 1512 Function2<AToB, BToA> f; // Top
1513 f = top; 1513 f = top;
1514 f = left; 1514 f = left;
1515 f = right; 1515 f = right;
1516 f = bot; 1516 f = bot;
1517 } 1517 }
(...skipping 28 matching lines...) Expand all
1546 class B extends A {} 1546 class B extends A {}
1547 1547
1548 typedef T Function2<S, T>(S z); 1548 typedef T Function2<S, T>(S z);
1549 1549
1550 typedef A BToA(B x); // Top of the base lattice 1550 typedef A BToA(B x); // Top of the base lattice
1551 typedef B AToB(A x); // Bot of the base lattice 1551 typedef B AToB(A x); // Bot of the base lattice
1552 1552
1553 BToA top(Function2<A, B> f) => f; 1553 BToA top(Function2<A, B> f) => f;
1554 AToB left(Function2<A, B> f) => f; 1554 AToB left(Function2<A, B> f) => f;
1555 BToA right(Function2<B, A> f) => f; 1555 BToA right(Function2<B, A> f) => f;
1556 AToB bot_(Function2<B, A> f) => /*warning:DOWN_CAST_COMPOSITE*/f; 1556 AToB bot_(Function2<B, A> f) => /*info:DOWN_CAST_COMPOSITE*/f;
1557 AToB bot(Function2<B, A> f) => f as AToB; 1557 AToB bot(Function2<B, A> f) => f as AToB;
1558 1558
1559 void main() { 1559 void main() {
1560 { 1560 {
1561 Function2<AToB, BToA> f; // Top 1561 Function2<AToB, BToA> f; // Top
1562 f = top; 1562 f = top;
1563 f = left; 1563 f = left;
1564 f = right; 1564 f = right;
1565 f = bot; 1565 f = bot;
1566 } 1566 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 Function2<Function2<A, B>, Function2<B, A>> top; 1601 Function2<Function2<A, B>, Function2<B, A>> top;
1602 Function2<Function2<B, A>, Function2<B, A>> right; 1602 Function2<Function2<B, A>, Function2<B, A>> right;
1603 Function2<Function2<A, B>, Function2<A, B>> left; 1603 Function2<Function2<A, B>, Function2<A, B>> left;
1604 Function2<Function2<B, A>, Function2<A, B>> bot; 1604 Function2<Function2<B, A>, Function2<A, B>> bot;
1605 1605
1606 top = right; 1606 top = right;
1607 top = bot; 1607 top = bot;
1608 top = top; 1608 top = top;
1609 top = left; 1609 top = left;
1610 1610
1611 left = /*warning:DOWN_CAST_COMPOSITE*/top; 1611 left = /*info:DOWN_CAST_COMPOSITE*/top;
1612 left = left; 1612 left = left;
1613 left = 1613 left =
1614 /*error:INVALID_ASSIGNMENT*/right; 1614 /*error:INVALID_ASSIGNMENT*/right;
1615 left = bot; 1615 left = bot;
1616 1616
1617 right = /*warning:DOWN_CAST_COMPOSITE*/top; 1617 right = /*info:DOWN_CAST_COMPOSITE*/top;
1618 right = 1618 right =
1619 /*error:INVALID_ASSIGNMENT*/left; 1619 /*error:INVALID_ASSIGNMENT*/left;
1620 right = right; 1620 right = right;
1621 right = bot; 1621 right = bot;
1622 1622
1623 bot = /*warning:DOWN_CAST_COMPOSITE*/top; 1623 bot = /*info:DOWN_CAST_COMPOSITE*/top;
1624 bot = /*warning:DOWN_CAST_COMPOSITE*/left; 1624 bot = /*info:DOWN_CAST_COMPOSITE*/left;
1625 bot = /*warning:DOWN_CAST_COMPOSITE*/right; 1625 bot = /*info:DOWN_CAST_COMPOSITE*/right;
1626 bot = bot; 1626 bot = bot;
1627 } 1627 }
1628 } 1628 }
1629 '''); 1629 ''');
1630 } 1630 }
1631 1631
1632 test_functionTypingAndSubtyping_instanceMethodVariance() async { 1632 test_functionTypingAndSubtyping_instanceMethodVariance() async {
1633 await checkFile(''' 1633 await checkFile('''
1634 class A {} 1634 class A {}
1635 class B extends A {} 1635 class B extends A {}
(...skipping 11 matching lines...) Expand all
1647 C c = new C(); 1647 C c = new C();
1648 { 1648 {
1649 Function2<B, A> f; 1649 Function2<B, A> f;
1650 f = c.top; 1650 f = c.top;
1651 f = c.left; 1651 f = c.left;
1652 f = c.right; 1652 f = c.right;
1653 f = c.bot; 1653 f = c.bot;
1654 } 1654 }
1655 { 1655 {
1656 Function2<B, B> f; 1656 Function2<B, B> f;
1657 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1657 f = /*info:DOWN_CAST_COMPOSITE*/c.top;
1658 f = c.left; 1658 f = c.left;
1659 f = /*error:INVALID_ASSIGNMENT*/c.right; 1659 f = /*error:INVALID_ASSIGNMENT*/c.right;
1660 f = c.bot; 1660 f = c.bot;
1661 } 1661 }
1662 { 1662 {
1663 Function2<A, A> f; 1663 Function2<A, A> f;
1664 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1664 f = /*info:DOWN_CAST_COMPOSITE*/c.top;
1665 f = /*error:INVALID_ASSIGNMENT*/c.left; 1665 f = /*error:INVALID_ASSIGNMENT*/c.left;
1666 f = c.right; 1666 f = c.right;
1667 f = c.bot; 1667 f = c.bot;
1668 } 1668 }
1669 { 1669 {
1670 Function2<A, B> f; 1670 Function2<A, B> f;
1671 f = /*warning:DOWN_CAST_COMPOSITE*/c.top; 1671 f = /*info:DOWN_CAST_COMPOSITE*/c.top;
1672 f = /*warning:DOWN_CAST_COMPOSITE*/c.left; 1672 f = /*info:DOWN_CAST_COMPOSITE*/c.left;
1673 f = /*warning:DOWN_CAST_COMPOSITE*/c.right; 1673 f = /*info:DOWN_CAST_COMPOSITE*/c.right;
1674 f = c.bot; 1674 f = c.bot;
1675 } 1675 }
1676 } 1676 }
1677 '''); 1677 ''');
1678 } 1678 }
1679 1679
1680 test_functionTypingAndSubtyping_intAndObject() async { 1680 test_functionTypingAndSubtyping_intAndObject() async {
1681 await checkFile(''' 1681 await checkFile('''
1682 typedef Object Top(int x); // Top of the lattice 1682 typedef Object Top(int x); // Top of the lattice
1683 typedef int Left(int x); // Left branch 1683 typedef int Left(int x); // Left branch
(...skipping 21 matching lines...) Expand all
1705 } 1705 }
1706 { 1706 {
1707 Top f; 1707 Top f;
1708 f = top; 1708 f = top;
1709 f = left; 1709 f = left;
1710 f = right; 1710 f = right;
1711 f = bot; 1711 f = bot;
1712 } 1712 }
1713 { 1713 {
1714 Left f; 1714 Left f;
1715 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1715 f = /*info:DOWN_CAST_COMPOSITE*/top;
1716 f = left; 1716 f = left;
1717 f = /*error:INVALID_ASSIGNMENT*/right; 1717 f = /*error:INVALID_ASSIGNMENT*/right;
1718 f = bot; 1718 f = bot;
1719 } 1719 }
1720 { 1720 {
1721 Right f; 1721 Right f;
1722 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1722 f = /*info:DOWN_CAST_COMPOSITE*/top;
1723 f = /*error:INVALID_ASSIGNMENT*/left; 1723 f = /*error:INVALID_ASSIGNMENT*/left;
1724 f = right; 1724 f = right;
1725 f = bot; 1725 f = bot;
1726 } 1726 }
1727 { 1727 {
1728 Bot f; 1728 Bot f;
1729 f = /*warning:DOWN_CAST_COMPOSITE*/top; 1729 f = /*info:DOWN_CAST_COMPOSITE*/top;
1730 f = /*warning:DOWN_CAST_COMPOSITE*/left; 1730 f = /*info:DOWN_CAST_COMPOSITE*/left;
1731 f = /*warning:DOWN_CAST_COMPOSITE*/right; 1731 f = /*info:DOWN_CAST_COMPOSITE*/right;
1732 f = bot; 1732 f = bot;
1733 } 1733 }
1734 } 1734 }
1735 '''); 1735 ''');
1736 } 1736 }
1737 1737
1738 test_functionTypingAndSubtyping_namedAndOptionalParameters() async { 1738 test_functionTypingAndSubtyping_namedAndOptionalParameters() async {
1739 await checkFile(''' 1739 await checkFile('''
1740 class A {} 1740 class A {}
1741 1741
(...skipping 21 matching lines...) Expand all
1763 r = r; 1763 r = r;
1764 r = o; 1764 r = o;
1765 r = /*error:INVALID_ASSIGNMENT*/n; 1765 r = /*error:INVALID_ASSIGNMENT*/n;
1766 r = /*error:INVALID_ASSIGNMENT*/rr; 1766 r = /*error:INVALID_ASSIGNMENT*/rr;
1767 r = ro; 1767 r = ro;
1768 r = rn; 1768 r = rn;
1769 r = oo; 1769 r = oo;
1770 r = /*error:INVALID_ASSIGNMENT*/nn; 1770 r = /*error:INVALID_ASSIGNMENT*/nn;
1771 r = /*error:INVALID_ASSIGNMENT*/nnn; 1771 r = /*error:INVALID_ASSIGNMENT*/nnn;
1772 1772
1773 o = /*warning:DOWN_CAST_COMPOSITE*/r; 1773 o = /*info:DOWN_CAST_COMPOSITE*/r;
1774 o = o; 1774 o = o;
1775 o = /*error:INVALID_ASSIGNMENT*/n; 1775 o = /*error:INVALID_ASSIGNMENT*/n;
1776 o = /*error:INVALID_ASSIGNMENT*/rr; 1776 o = /*error:INVALID_ASSIGNMENT*/rr;
1777 o = /*error:INVALID_ASSIGNMENT*/ro; 1777 o = /*error:INVALID_ASSIGNMENT*/ro;
1778 o = /*error:INVALID_ASSIGNMENT*/rn; 1778 o = /*error:INVALID_ASSIGNMENT*/rn;
1779 o = oo; 1779 o = oo;
1780 o = /*error:INVALID_ASSIGNMENT*/nn; 1780 o = /*error:INVALID_ASSIGNMENT*/nn;
1781 o = /*error:INVALID_ASSIGNMENT*/nnn; 1781 o = /*error:INVALID_ASSIGNMENT*/nnn;
1782 1782
1783 n = /*error:INVALID_ASSIGNMENT*/r; 1783 n = /*error:INVALID_ASSIGNMENT*/r;
1784 n = /*error:INVALID_ASSIGNMENT*/o; 1784 n = /*error:INVALID_ASSIGNMENT*/o;
1785 n = n; 1785 n = n;
1786 n = /*error:INVALID_ASSIGNMENT*/rr; 1786 n = /*error:INVALID_ASSIGNMENT*/rr;
1787 n = /*error:INVALID_ASSIGNMENT*/ro; 1787 n = /*error:INVALID_ASSIGNMENT*/ro;
1788 n = /*error:INVALID_ASSIGNMENT*/rn; 1788 n = /*error:INVALID_ASSIGNMENT*/rn;
1789 n = /*error:INVALID_ASSIGNMENT*/oo; 1789 n = /*error:INVALID_ASSIGNMENT*/oo;
1790 n = nn; 1790 n = nn;
1791 n = nnn; 1791 n = nnn;
1792 1792
1793 rr = /*error:INVALID_ASSIGNMENT*/r; 1793 rr = /*error:INVALID_ASSIGNMENT*/r;
1794 rr = /*error:INVALID_ASSIGNMENT*/o; 1794 rr = /*error:INVALID_ASSIGNMENT*/o;
1795 rr = /*error:INVALID_ASSIGNMENT*/n; 1795 rr = /*error:INVALID_ASSIGNMENT*/n;
1796 rr = rr; 1796 rr = rr;
1797 rr = ro; 1797 rr = ro;
1798 rr = /*error:INVALID_ASSIGNMENT*/rn; 1798 rr = /*error:INVALID_ASSIGNMENT*/rn;
1799 rr = oo; 1799 rr = oo;
1800 rr = /*error:INVALID_ASSIGNMENT*/nn; 1800 rr = /*error:INVALID_ASSIGNMENT*/nn;
1801 rr = /*error:INVALID_ASSIGNMENT*/nnn; 1801 rr = /*error:INVALID_ASSIGNMENT*/nnn;
1802 1802
1803 ro = /*warning:DOWN_CAST_COMPOSITE*/r; 1803 ro = /*info:DOWN_CAST_COMPOSITE*/r;
1804 ro = /*error:INVALID_ASSIGNMENT*/o; 1804 ro = /*error:INVALID_ASSIGNMENT*/o;
1805 ro = /*error:INVALID_ASSIGNMENT*/n; 1805 ro = /*error:INVALID_ASSIGNMENT*/n;
1806 ro = /*warning:DOWN_CAST_COMPOSITE*/rr; 1806 ro = /*info:DOWN_CAST_COMPOSITE*/rr;
1807 ro = ro; 1807 ro = ro;
1808 ro = /*error:INVALID_ASSIGNMENT*/rn; 1808 ro = /*error:INVALID_ASSIGNMENT*/rn;
1809 ro = oo; 1809 ro = oo;
1810 ro = /*error:INVALID_ASSIGNMENT*/nn; 1810 ro = /*error:INVALID_ASSIGNMENT*/nn;
1811 ro = /*error:INVALID_ASSIGNMENT*/nnn; 1811 ro = /*error:INVALID_ASSIGNMENT*/nnn;
1812 1812
1813 rn = /*warning:DOWN_CAST_COMPOSITE*/r; 1813 rn = /*info:DOWN_CAST_COMPOSITE*/r;
1814 rn = /*error:INVALID_ASSIGNMENT*/o; 1814 rn = /*error:INVALID_ASSIGNMENT*/o;
1815 rn = /*error:INVALID_ASSIGNMENT*/n; 1815 rn = /*error:INVALID_ASSIGNMENT*/n;
1816 rn = /*error:INVALID_ASSIGNMENT*/rr; 1816 rn = /*error:INVALID_ASSIGNMENT*/rr;
1817 rn = /*error:INVALID_ASSIGNMENT*/ro; 1817 rn = /*error:INVALID_ASSIGNMENT*/ro;
1818 rn = rn; 1818 rn = rn;
1819 rn = /*error:INVALID_ASSIGNMENT*/oo; 1819 rn = /*error:INVALID_ASSIGNMENT*/oo;
1820 rn = /*error:INVALID_ASSIGNMENT*/nn; 1820 rn = /*error:INVALID_ASSIGNMENT*/nn;
1821 rn = /*error:INVALID_ASSIGNMENT*/nnn; 1821 rn = /*error:INVALID_ASSIGNMENT*/nnn;
1822 1822
1823 oo = /*warning:DOWN_CAST_COMPOSITE*/r; 1823 oo = /*info:DOWN_CAST_COMPOSITE*/r;
1824 oo = /*warning:DOWN_CAST_COMPOSITE*/o; 1824 oo = /*info:DOWN_CAST_COMPOSITE*/o;
1825 oo = /*error:INVALID_ASSIGNMENT*/n; 1825 oo = /*error:INVALID_ASSIGNMENT*/n;
1826 oo = /*warning:DOWN_CAST_COMPOSITE*/rr; 1826 oo = /*info:DOWN_CAST_COMPOSITE*/rr;
1827 oo = /*warning:DOWN_CAST_COMPOSITE*/ro; 1827 oo = /*info:DOWN_CAST_COMPOSITE*/ro;
1828 oo = /*error:INVALID_ASSIGNMENT*/rn; 1828 oo = /*error:INVALID_ASSIGNMENT*/rn;
1829 oo = oo; 1829 oo = oo;
1830 oo = /*error:INVALID_ASSIGNMENT*/nn; 1830 oo = /*error:INVALID_ASSIGNMENT*/nn;
1831 oo = /*error:INVALID_ASSIGNMENT*/nnn; 1831 oo = /*error:INVALID_ASSIGNMENT*/nnn;
1832 1832
1833 nn = /*error:INVALID_ASSIGNMENT*/r; 1833 nn = /*error:INVALID_ASSIGNMENT*/r;
1834 nn = /*error:INVALID_ASSIGNMENT*/o; 1834 nn = /*error:INVALID_ASSIGNMENT*/o;
1835 nn = /*warning:DOWN_CAST_COMPOSITE*/n; 1835 nn = /*info:DOWN_CAST_COMPOSITE*/n;
1836 nn = /*error:INVALID_ASSIGNMENT*/rr; 1836 nn = /*error:INVALID_ASSIGNMENT*/rr;
1837 nn = /*error:INVALID_ASSIGNMENT*/ro; 1837 nn = /*error:INVALID_ASSIGNMENT*/ro;
1838 nn = /*error:INVALID_ASSIGNMENT*/rn; 1838 nn = /*error:INVALID_ASSIGNMENT*/rn;
1839 nn = /*error:INVALID_ASSIGNMENT*/oo; 1839 nn = /*error:INVALID_ASSIGNMENT*/oo;
1840 nn = nn; 1840 nn = nn;
1841 nn = nnn; 1841 nn = nnn;
1842 1842
1843 nnn = /*error:INVALID_ASSIGNMENT*/r; 1843 nnn = /*error:INVALID_ASSIGNMENT*/r;
1844 nnn = /*error:INVALID_ASSIGNMENT*/o; 1844 nnn = /*error:INVALID_ASSIGNMENT*/o;
1845 nnn = /*warning:DOWN_CAST_COMPOSITE*/n; 1845 nnn = /*info:DOWN_CAST_COMPOSITE*/n;
1846 nnn = /*error:INVALID_ASSIGNMENT*/rr; 1846 nnn = /*error:INVALID_ASSIGNMENT*/rr;
1847 nnn = /*error:INVALID_ASSIGNMENT*/ro; 1847 nnn = /*error:INVALID_ASSIGNMENT*/ro;
1848 nnn = /*error:INVALID_ASSIGNMENT*/rn; 1848 nnn = /*error:INVALID_ASSIGNMENT*/rn;
1849 nnn = /*error:INVALID_ASSIGNMENT*/oo; 1849 nnn = /*error:INVALID_ASSIGNMENT*/oo;
1850 nnn = /*warning:DOWN_CAST_COMPOSITE*/nn; 1850 nnn = /*info:DOWN_CAST_COMPOSITE*/nn;
1851 nnn = nnn; 1851 nnn = nnn;
1852 } 1852 }
1853 '''); 1853 ''');
1854 } 1854 }
1855 1855
1856 test_functionTypingAndSubtyping_objectsWithCallMethods() async { 1856 test_functionTypingAndSubtyping_objectsWithCallMethods() async {
1857 await checkFile(''' 1857 await checkFile('''
1858 typedef int I2I(int x); 1858 typedef int I2I(int x);
1859 typedef num N2N(num x); 1859 typedef num N2N(num x);
1860 class A { 1860 class A {
1861 int call(int x) => x; 1861 int call(int x) => x;
1862 } 1862 }
1863 class B { 1863 class B {
1864 num call(num x) => x; 1864 num call(num x) => x;
1865 } 1865 }
1866 int i2i(int x) => x; 1866 int i2i(int x) => x;
1867 num n2n(num x) => x; 1867 num n2n(num x) => x;
1868 void main() { 1868 void main() {
1869 { 1869 {
1870 I2I f; 1870 I2I f;
1871 f = new A(); 1871 f = new A();
1872 f = /*error:INVALID_ASSIGNMENT*/new B(); 1872 f = /*error:INVALID_ASSIGNMENT*/new B();
1873 f = i2i; 1873 f = i2i;
1874 f = /*error:INVALID_ASSIGNMENT*/n2n; 1874 f = /*error:INVALID_ASSIGNMENT*/n2n;
1875 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/i2i as Object; 1875 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_COMPOSITE*/i2i as Object;
1876 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/n2n as Function; 1876 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_COMPOSITE*/n2n as Function;
1877 } 1877 }
1878 { 1878 {
1879 N2N f; 1879 N2N f;
1880 f = /*error:INVALID_ASSIGNMENT*/new A(); 1880 f = /*error:INVALID_ASSIGNMENT*/new A();
1881 f = new B(); 1881 f = new B();
1882 f = /*error:INVALID_ASSIGNMENT*/i2i; 1882 f = /*error:INVALID_ASSIGNMENT*/i2i;
1883 f = n2n; 1883 f = n2n;
1884 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/i2i as Object; 1884 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_COMPOSITE*/i2i as Object;
1885 f = /*info:UNNECESSARY_CAST,warning:DOWN_CAST_COMPOSITE*/n2n as Function; 1885 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_COMPOSITE*/n2n as Function;
1886 } 1886 }
1887 { 1887 {
1888 A f; 1888 A f;
1889 f = new A(); 1889 f = new A();
1890 f = /*error:INVALID_ASSIGNMENT*/new B(); 1890 f = /*error:INVALID_ASSIGNMENT*/new B();
1891 f = /*error:INVALID_ASSIGNMENT*/i2i; 1891 f = /*error:INVALID_ASSIGNMENT*/i2i;
1892 f = /*error:INVALID_ASSIGNMENT*/n2n; 1892 f = /*error:INVALID_ASSIGNMENT*/n2n;
1893 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/i2i as Object; 1893 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/i2i as Object;
1894 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/n2n as Function; 1894 f = /*info:UNNECESSARY_CAST,info:DOWN_CAST_IMPLICIT*/n2n as Function;
1895 } 1895 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 { 1980 {
1981 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null; 1981 Iterable/*<R>*/ f/*<P, R>*/(List/*<P>*/ p) => null;
1982 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null; 1982 List/*<T>*/ g/*<S, T>*/(Iterable/*<S>*/ s) => null;
1983 1983
1984 var local = f; 1984 var local = f;
1985 local = g; // valid 1985 local = g; // valid
1986 1986
1987 var local2 = g; 1987 var local2 = g;
1988 local = local2; 1988 local = local2;
1989 local2 = /*error:INVALID_CAST_FUNCTION*/f; 1989 local2 = /*error:INVALID_CAST_FUNCTION*/f;
1990 local2 = /*warning:DOWN_CAST_COMPOSITE*/local; 1990 local2 = /*info:DOWN_CAST_COMPOSITE*/local;
1991 1991
1992 // Non-generic function cannot subtype a generic one. 1992 // Non-generic function cannot subtype a generic one.
1993 local = /*error:INVALID_ASSIGNMENT*/(x) => null; 1993 local = /*error:INVALID_ASSIGNMENT*/(x) => null;
1994 local = /*error:INVALID_ASSIGNMENT*/nonGenericFn; 1994 local = /*error:INVALID_ASSIGNMENT*/nonGenericFn;
1995 } 1995 }
1996 } 1996 }
1997 '''); 1997 ''');
1998 } 1998 }
1999 1999
2000 test_functionTypingAndSubtyping_uninferredClosure() async { 2000 test_functionTypingAndSubtyping_uninferredClosure() async {
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2833 } 2833 }
2834 // TODO(leafp): This case isn't handled yet. This test checks 2834 // TODO(leafp): This case isn't handled yet. This test checks
2835 // the case where two related classes are instantiated with related 2835 // the case where two related classes are instantiated with related
2836 // but different types. 2836 // but different types.
2837 Iterable<num> test2(bool b) { 2837 Iterable<num> test2(bool b) {
2838 List<int> li; 2838 List<int> li;
2839 Iterable<double> id; 2839 Iterable<double> id;
2840 int x = 2840 int x =
2841 /*info:ASSIGNMENT_CAST should be error:INVALID_ASSIGNMENT*/ 2841 /*info:ASSIGNMENT_CAST should be error:INVALID_ASSIGNMENT*/
2842 b ? li : id; 2842 b ? li : id;
2843 return /*warning:DOWN_CAST_COMPOSITE should be pass*/b ? li : id; 2843 return /*info:DOWN_CAST_COMPOSITE should be pass*/b ? li : id;
2844 } 2844 }
2845 } 2845 }
2846 '''); 2846 ''');
2847 } 2847 }
2848 2848
2849 test_leastUpperBounds_fuzzyArrows() async { 2849 test_leastUpperBounds_fuzzyArrows() async {
2850 await checkFile(r''' 2850 await checkFile(r'''
2851 typedef String TakesA<T>(T item); 2851 typedef String TakesA<T>(T item);
2852 2852
2853 void main() { 2853 void main() {
2854 TakesA<int> f; 2854 TakesA<int> f;
2855 TakesA<dynamic> g; 2855 TakesA<dynamic> g;
2856 TakesA<String> h; 2856 TakesA<String> h;
2857 g = h; 2857 g = h;
2858 f = /*warning:DOWN_CAST_COMPOSITE*/f ?? g; 2858 f = /*info:DOWN_CAST_COMPOSITE*/f ?? g;
2859 } 2859 }
2860 '''); 2860 ''');
2861 } 2861 }
2862 2862
2863 test_loadLibrary() async { 2863 test_loadLibrary() async {
2864 addFile('''library lib1;''', name: '/lib1.dart'); 2864 addFile('''library lib1;''', name: '/lib1.dart');
2865 await checkFile(r''' 2865 await checkFile(r'''
2866 import 'lib1.dart' deferred as lib1; 2866 import 'lib1.dart' deferred as lib1;
2867 import 'dart:async' show Future; 2867 import 'dart:async' show Future;
2868 main() { 2868 main() {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3397 lOfOs = mOfAs; 3397 lOfOs = mOfAs;
3398 lOfOs = lOfDs; 3398 lOfOs = lOfDs;
3399 lOfOs = lOfOs; 3399 lOfOs = lOfOs;
3400 lOfOs = lOfAs; 3400 lOfOs = lOfAs;
3401 lOfOs = new L<Object>(); // Reset type propagation. 3401 lOfOs = new L<Object>(); // Reset type propagation.
3402 } 3402 }
3403 { 3403 {
3404 lOfAs = /*error:INVALID_ASSIGNMENT*/mOfDs; 3404 lOfAs = /*error:INVALID_ASSIGNMENT*/mOfDs;
3405 lOfAs = /*error:INVALID_ASSIGNMENT*/mOfOs; 3405 lOfAs = /*error:INVALID_ASSIGNMENT*/mOfOs;
3406 lOfAs = mOfAs; 3406 lOfAs = mOfAs;
3407 lOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; 3407 lOfAs = /*info:DOWN_CAST_COMPOSITE*/lOfDs;
3408 lOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; 3408 lOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs;
3409 lOfAs = lOfAs; 3409 lOfAs = lOfAs;
3410 lOfAs = new L<A>(); // Reset type propagation. 3410 lOfAs = new L<A>(); // Reset type propagation.
3411 } 3411 }
3412 { 3412 {
3413 mOfDs = mOfDs; 3413 mOfDs = mOfDs;
3414 mOfDs = mOfOs; 3414 mOfDs = mOfOs;
3415 mOfDs = mOfAs; 3415 mOfDs = mOfAs;
3416 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; 3416 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfDs;
3417 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; 3417 mOfDs = /*info:DOWN_CAST_IMPLICIT*/lOfOs;
3418 mOfDs = /*error:INVALID_ASSIGNMENT*/lOfAs; 3418 mOfDs = /*error:INVALID_ASSIGNMENT*/lOfAs;
3419 mOfDs = new M(); // Reset type propagation. 3419 mOfDs = new M(); // Reset type propagation.
3420 } 3420 }
3421 { 3421 {
3422 mOfOs = mOfDs; 3422 mOfOs = mOfDs;
3423 mOfOs = mOfOs; 3423 mOfOs = mOfOs;
3424 mOfOs = mOfAs; 3424 mOfOs = mOfAs;
3425 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfDs; 3425 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfDs;
3426 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; 3426 mOfOs = /*info:DOWN_CAST_IMPLICIT*/lOfOs;
3427 mOfOs = /*error:INVALID_ASSIGNMENT*/lOfAs; 3427 mOfOs = /*error:INVALID_ASSIGNMENT*/lOfAs;
3428 mOfOs = new M<Object>(); // Reset type propagation. 3428 mOfOs = new M<Object>(); // Reset type propagation.
3429 } 3429 }
3430 { 3430 {
3431 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/mOfDs; 3431 mOfAs = /*info:DOWN_CAST_COMPOSITE*/mOfDs;
3432 mOfAs = /*info:DOWN_CAST_IMPLICIT*/mOfOs; 3432 mOfAs = /*info:DOWN_CAST_IMPLICIT*/mOfOs;
3433 mOfAs = mOfAs; 3433 mOfAs = mOfAs;
3434 mOfAs = /*warning:DOWN_CAST_COMPOSITE*/lOfDs; 3434 mOfAs = /*info:DOWN_CAST_COMPOSITE*/lOfDs;
3435 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs; 3435 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfOs;
3436 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfAs; 3436 mOfAs = /*info:DOWN_CAST_IMPLICIT*/lOfAs;
3437 } 3437 }
3438 } 3438 }
3439 '''); 3439 ''');
3440 } 3440 }
3441 3441
3442 test_setterOverride_fuzzyArrows() async { 3442 test_setterOverride_fuzzyArrows() async {
3443 await checkFile(''' 3443 await checkFile('''
3444 typedef void ToVoid<T>(T x); 3444 typedef void ToVoid<T>(T x);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3727 // type is effectively: (Object, Object) -> int 3727 // type is effectively: (Object, Object) -> int
3728 // We are assigning it a fn of type: (Comparable, Comparable) -> int 3728 // We are assigning it a fn of type: (Comparable, Comparable) -> int
3729 // There's no telling if that will work. For example, consider: 3729 // There's no telling if that will work. For example, consider:
3730 // 3730 //
3731 // new SplayTreeMap<Uri>(); 3731 // new SplayTreeMap<Uri>();
3732 // 3732 //
3733 // This would end up calling .compareTo() on a Uri, which doesn't 3733 // This would end up calling .compareTo() on a Uri, which doesn't
3734 // define that since it doesn't implement Comparable. 3734 // define that since it doesn't implement Comparable.
3735 SplayTreeMap([int compare(K key1, K key2), 3735 SplayTreeMap([int compare(K key1, K key2),
3736 bool isValidKey(potentialKey)]) 3736 bool isValidKey(potentialKey)])
3737 : _comparator = /*warning:DOWN_CAST_COMPOSITE*/(compare == null) ? Comparabl e.compare : compare, 3737 : _comparator = /*info:DOWN_CAST_COMPOSITE*/(compare == null) ? Comparable.c ompare : compare,
3738 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) { 3738 _validKey = (isValidKey != null) ? isValidKey : ((v) => true) {
3739 3739
3740 // NOTE: this is a down cast because isValidKey has fuzzy arrow type. 3740 // NOTE: this is a down cast because isValidKey has fuzzy arrow type.
3741 _Predicate<Object> v = /*warning:DOWN_CAST_COMPOSITE*/(isValidKey != null) 3741 _Predicate<Object> v = /*info:DOWN_CAST_COMPOSITE*/(isValidKey != null)
3742 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); 3742 ? isValidKey : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
3743 3743
3744 v = (isValidKey != null) 3744 v = (isValidKey != null)
3745 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true); 3745 ? v : (/*info:INFERRED_TYPE_CLOSURE*/(_) => true);
3746 } 3746 }
3747 } 3747 }
3748 void main() { 3748 void main() {
3749 Object obj = 42; 3749 Object obj = 42;
3750 dynamic dyn = 42; 3750 dynamic dyn = 42;
3751 int i = 42; 3751 int i = 42;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
3856 // Regression test for: 3856 // Regression test for:
3857 // https://github.com/dart-lang/sdk/issues/27040 3857 // https://github.com/dart-lang/sdk/issues/27040
3858 await checkFile(r''' 3858 await checkFile(r'''
3859 void f/*<T extends num>*/(T x, T y) { 3859 void f/*<T extends num>*/(T x, T y) {
3860 var z = x; 3860 var z = x;
3861 var f = () => x; 3861 var f = () => x;
3862 f = () => y; 3862 f = () => y;
3863 if (x is int) { 3863 if (x is int) {
3864 /*info:DYNAMIC_INVOKE*/z./*error:UNDEFINED_GETTER*/isEven; 3864 /*info:DYNAMIC_INVOKE*/z./*error:UNDEFINED_GETTER*/isEven;
3865 var q = x; 3865 var q = x;
3866 q = /*warning:DOWN_CAST_COMPOSITE*/z; 3866 q = /*info:DOWN_CAST_COMPOSITE*/z;
3867 /*info:DYNAMIC_INVOKE*/f()./*error:UNDEFINED_GETTER*/isEven; 3867 /*info:DYNAMIC_INVOKE*/f()./*error:UNDEFINED_GETTER*/isEven;
3868 3868
3869 // This does not capture the type `T extends int`. Instead the return type 3869 // This does not capture the type `T extends int`. Instead the return type
3870 // is `T extends num`. What happens is we substitute {T/T} on the function 3870 // is `T extends num`. What happens is we substitute {T/T} on the function
3871 // type, and the way it is implemented, this leads back to `T extends num`. 3871 // type, and the way it is implemented, this leads back to `T extends num`.
3872 // See https://github.com/dart-lang/sdk/issues/27725 3872 // See https://github.com/dart-lang/sdk/issues/27725
3873 var g = () => x; 3873 var g = () => x;
3874 g = f; 3874 g = f;
3875 /*info:DYNAMIC_INVOKE*/g()./*error:UNDEFINED_GETTER*/isEven; 3875 /*info:DYNAMIC_INVOKE*/g()./*error:UNDEFINED_GETTER*/isEven;
3876 q = /*warning:DOWN_CAST_COMPOSITE*/g(); 3876 q = /*info:DOWN_CAST_COMPOSITE*/g();
3877 int r = x; 3877 int r = x;
3878 } 3878 }
3879 } 3879 }
3880 '''); 3880 ''');
3881 } 3881 }
3882 3882
3883 test_typeSubtyping_assigningClass() async { 3883 test_typeSubtyping_assigningClass() async {
3884 await checkFile(''' 3884 await checkFile('''
3885 class A {} 3885 class A {}
3886 class B extends A {} 3886 class B extends A {}
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
4143 class CheckerTest_Driver extends CheckerTest { 4143 class CheckerTest_Driver extends CheckerTest {
4144 @override 4144 @override
4145 bool get enableNewAnalysisDriver => true; 4145 bool get enableNewAnalysisDriver => true;
4146 4146
4147 @failingTest 4147 @failingTest
4148 @override 4148 @override
4149 test_covariantOverride_fields() async { 4149 test_covariantOverride_fields() async {
4150 await super.test_covariantOverride_fields(); 4150 await super.test_covariantOverride_fields();
4151 } 4151 }
4152 } 4152 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/error/codes.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