| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/dart/analysis/driver.dart'; | 8 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 10 | 10 |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 checkElementText( | 1070 checkElementText( |
| 1071 library, | 1071 library, |
| 1072 r''' | 1072 r''' |
| 1073 class A { | 1073 class A { |
| 1074 int f; | 1074 int f; |
| 1075 A([int this.f]); | 1075 A([int this.f]); |
| 1076 } | 1076 } |
| 1077 '''); | 1077 '''); |
| 1078 } | 1078 } |
| 1079 | 1079 |
| 1080 test_instanceField_fromAccessors_multiple_different() async { | |
| 1081 var library = await _encodeDecodeLibrary(r''' | |
| 1082 abstract class A { | |
| 1083 int get x; | |
| 1084 } | |
| 1085 abstract class B { | |
| 1086 void set x(String _); | |
| 1087 } | |
| 1088 class C implements A, B { | |
| 1089 var x; | |
| 1090 } | |
| 1091 '''); | |
| 1092 checkElementText( | |
| 1093 library, | |
| 1094 r''' | |
| 1095 abstract class A { | |
| 1096 int get x; | |
| 1097 } | |
| 1098 abstract class B { | |
| 1099 void set x(String _); | |
| 1100 } | |
| 1101 class C implements A, B { | |
| 1102 dynamic x/*error: overrideConflictFieldType*/; | |
| 1103 } | |
| 1104 '''); | |
| 1105 } | |
| 1106 | |
| 1107 test_instanceField_fromAccessors_multiple_same() async { | |
| 1108 var library = await _encodeDecodeLibrary(r''' | |
| 1109 abstract class A { | |
| 1110 int get x; | |
| 1111 } | |
| 1112 abstract class B { | |
| 1113 void set x(int _); | |
| 1114 } | |
| 1115 class C implements A, B { | |
| 1116 var x; | |
| 1117 } | |
| 1118 '''); | |
| 1119 checkElementText( | |
| 1120 library, | |
| 1121 r''' | |
| 1122 abstract class A { | |
| 1123 int get x; | |
| 1124 } | |
| 1125 abstract class B { | |
| 1126 void set x(int _); | |
| 1127 } | |
| 1128 class C implements A, B { | |
| 1129 int x; | |
| 1130 } | |
| 1131 '''); | |
| 1132 } | |
| 1133 | |
| 1134 test_instanceField_fromField() async { | 1080 test_instanceField_fromField() async { |
| 1135 var library = await _encodeDecodeLibrary(r''' | 1081 var library = await _encodeDecodeLibrary(r''' |
| 1136 abstract class A { | 1082 abstract class A { |
| 1137 int x; | 1083 int x; |
| 1138 int y; | 1084 int y; |
| 1139 int z; | 1085 int z; |
| 1140 } | 1086 } |
| 1141 class B implements A { | 1087 class B implements A { |
| 1142 var x; | 1088 var x; |
| 1143 get y => null; | 1089 get y => null; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 } | 1366 } |
| 1421 abstract class B { | 1367 abstract class B { |
| 1422 int get x; | 1368 int get x; |
| 1423 } | 1369 } |
| 1424 class C implements A, B { | 1370 class C implements A, B { |
| 1425 int get x {} | 1371 int get x {} |
| 1426 } | 1372 } |
| 1427 '''); | 1373 '''); |
| 1428 } | 1374 } |
| 1429 | 1375 |
| 1430 test_instanceField_fromGetterSetter_field() async { | 1376 test_instanceField_fromGetterSetter_different_field() async { |
| 1431 var library = await _encodeDecodeLibrary(r''' | 1377 var library = await _encodeDecodeLibrary(r''' |
| 1432 abstract class A { | 1378 abstract class A { |
| 1433 int get x; | 1379 int get x; |
| 1380 int get y; |
| 1381 } |
| 1382 abstract class B { |
| 1383 void set x(String _); |
| 1384 void set y(String _); |
| 1385 } |
| 1386 class C implements A, B { |
| 1387 var x; |
| 1388 final y; |
| 1389 } |
| 1390 '''); |
| 1391 checkElementText( |
| 1392 library, |
| 1393 r''' |
| 1394 abstract class A { |
| 1395 int get x; |
| 1396 int get y; |
| 1397 } |
| 1398 abstract class B { |
| 1399 void set x(String _); |
| 1400 void set y(String _); |
| 1401 } |
| 1402 class C implements A, B { |
| 1403 dynamic x/*error: overrideConflictFieldType*/; |
| 1404 final int y; |
| 1405 } |
| 1406 '''); |
| 1407 } |
| 1408 |
| 1409 test_instanceField_fromGetterSetter_different_getter() async { |
| 1410 var library = await _encodeDecodeLibrary(r''' |
| 1411 abstract class A { |
| 1412 int get x; |
| 1413 } |
| 1414 abstract class B { |
| 1415 void set x(String _); |
| 1416 } |
| 1417 class C implements A, B { |
| 1418 get x => null; |
| 1419 } |
| 1420 '''); |
| 1421 checkElementText( |
| 1422 library, |
| 1423 r''' |
| 1424 abstract class A { |
| 1425 synthetic final int x; |
| 1426 int get x; |
| 1427 } |
| 1428 abstract class B { |
| 1429 synthetic String x; |
| 1430 void set x(String _); |
| 1431 } |
| 1432 class C implements A, B { |
| 1433 synthetic final int x; |
| 1434 int get x {} |
| 1435 } |
| 1436 ''', |
| 1437 withSyntheticFields: true); |
| 1438 } |
| 1439 |
| 1440 test_instanceField_fromGetterSetter_different_setter() async { |
| 1441 var library = await _encodeDecodeLibrary(r''' |
| 1442 abstract class A { |
| 1443 int get x; |
| 1444 } |
| 1445 abstract class B { |
| 1446 void set x(String _); |
| 1447 } |
| 1448 class C implements A, B { |
| 1449 set x(_); |
| 1450 } |
| 1451 '''); |
| 1452 // TODO(scheglov) test for inference failure error |
| 1453 checkElementText( |
| 1454 library, |
| 1455 r''' |
| 1456 abstract class A { |
| 1457 synthetic final int x; |
| 1458 int get x; |
| 1459 } |
| 1460 abstract class B { |
| 1461 synthetic String x; |
| 1462 void set x(String _); |
| 1463 } |
| 1464 class C implements A, B { |
| 1465 synthetic dynamic x; |
| 1466 void set x(dynamic _); |
| 1467 } |
| 1468 ''', |
| 1469 withSyntheticFields: true); |
| 1470 } |
| 1471 |
| 1472 test_instanceField_fromGetterSetter_same_field() async { |
| 1473 var library = await _encodeDecodeLibrary(r''' |
| 1474 abstract class A { |
| 1475 int get x; |
| 1434 } | 1476 } |
| 1435 abstract class B { | 1477 abstract class B { |
| 1436 void set x(int _); | 1478 void set x(int _); |
| 1437 } | 1479 } |
| 1438 class C implements A, B { | 1480 class C implements A, B { |
| 1439 var x; | 1481 var x; |
| 1440 } | 1482 } |
| 1441 '''); | 1483 '''); |
| 1442 checkElementText( | 1484 checkElementText( |
| 1443 library, | 1485 library, |
| 1444 r''' | 1486 r''' |
| 1445 abstract class A { | 1487 abstract class A { |
| 1446 int get x; | 1488 int get x; |
| 1447 } | 1489 } |
| 1448 abstract class B { | 1490 abstract class B { |
| 1449 void set x(int _); | 1491 void set x(int _); |
| 1450 } | 1492 } |
| 1451 class C implements A, B { | 1493 class C implements A, B { |
| 1452 int x; | 1494 int x; |
| 1453 } | 1495 } |
| 1454 '''); | 1496 '''); |
| 1455 } | 1497 } |
| 1456 | 1498 |
| 1457 test_instanceField_fromGetterSetter_getter() async { | 1499 test_instanceField_fromGetterSetter_same_getter() async { |
| 1458 var library = await _encodeDecodeLibrary(r''' | 1500 var library = await _encodeDecodeLibrary(r''' |
| 1459 abstract class A { | 1501 abstract class A { |
| 1460 int get x; | 1502 int get x; |
| 1461 } | 1503 } |
| 1462 abstract class B { | 1504 abstract class B { |
| 1463 void set x(int _); | 1505 void set x(int _); |
| 1464 } | 1506 } |
| 1465 class C implements A, B { | 1507 class C implements A, B { |
| 1466 get x => null; | 1508 get x => null; |
| 1467 } | 1509 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1478 void set x(int _); | 1520 void set x(int _); |
| 1479 } | 1521 } |
| 1480 class C implements A, B { | 1522 class C implements A, B { |
| 1481 synthetic final int x; | 1523 synthetic final int x; |
| 1482 int get x {} | 1524 int get x {} |
| 1483 } | 1525 } |
| 1484 ''', | 1526 ''', |
| 1485 withSyntheticFields: true); | 1527 withSyntheticFields: true); |
| 1486 } | 1528 } |
| 1487 | 1529 |
| 1488 test_instanceField_fromGetterSetter_setter() async { | 1530 test_instanceField_fromGetterSetter_same_setter() async { |
| 1489 var library = await _encodeDecodeLibrary(r''' | 1531 var library = await _encodeDecodeLibrary(r''' |
| 1490 abstract class A { | 1532 abstract class A { |
| 1491 int get x; | 1533 int get x; |
| 1492 } | 1534 } |
| 1493 abstract class B { | 1535 abstract class B { |
| 1494 void set x(String _); | 1536 void set x(int _); |
| 1495 } | 1537 } |
| 1496 class C implements A, B { | 1538 class C implements A, B { |
| 1497 set x(_); | 1539 set x(_); |
| 1498 } | 1540 } |
| 1499 '''); | 1541 '''); |
| 1500 checkElementText( | 1542 checkElementText( |
| 1501 library, | 1543 library, |
| 1502 r''' | 1544 r''' |
| 1503 abstract class A { | 1545 abstract class A { |
| 1504 synthetic final int x; | 1546 synthetic final int x; |
| 1505 int get x; | 1547 int get x; |
| 1506 } | 1548 } |
| 1507 abstract class B { | 1549 abstract class B { |
| 1508 synthetic String x; | 1550 synthetic int x; |
| 1509 void set x(String _); | 1551 void set x(int _); |
| 1510 } | 1552 } |
| 1511 class C implements A, B { | 1553 class C implements A, B { |
| 1512 synthetic dynamic x; | 1554 synthetic int x; |
| 1513 void set x(dynamic _); | 1555 void set x(int _); |
| 1514 } | 1556 } |
| 1515 ''', | 1557 ''', |
| 1516 withSyntheticFields: true); | 1558 withSyntheticFields: true); |
| 1517 } | 1559 } |
| 1518 | 1560 |
| 1519 test_instanceField_fromSetter() async { | 1561 test_instanceField_fromSetter() async { |
| 1520 var library = await _encodeDecodeLibrary(r''' | 1562 var library = await _encodeDecodeLibrary(r''' |
| 1521 abstract class A { | 1563 abstract class A { |
| 1522 void set x(int _); | 1564 void set x(int _); |
| 1523 void set y(int _); | 1565 void set y(int _); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 | 2334 |
| 2293 Future<LibraryElement> _encodeDecodeLibrary(String text) async { | 2335 Future<LibraryElement> _encodeDecodeLibrary(String text) async { |
| 2294 String path = _p('/test.dart'); | 2336 String path = _p('/test.dart'); |
| 2295 provider.newFile(path, text); | 2337 provider.newFile(path, text); |
| 2296 UnitElementResult result = await driver.getUnitElement(path); | 2338 UnitElementResult result = await driver.getUnitElement(path); |
| 2297 return result.element.library; | 2339 return result.element.library; |
| 2298 } | 2340 } |
| 2299 | 2341 |
| 2300 String _p(String path) => provider.convertPath(path); | 2342 String _p(String path) => provider.convertPath(path); |
| 2301 } | 2343 } |
| OLD | NEW |