| OLD | NEW |
| 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 /// General type checking tests | 5 /// General type checking tests |
| 6 library dev_compiler.test.checker_test; | 6 library dev_compiler.test.checker_test; |
| 7 | 7 |
| 8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
| 9 | 9 |
| 10 import '../testing.dart'; | 10 import '../testing.dart'; |
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1481 void set f1(B value); | 1481 void set f1(B value); |
| 1482 void set f2(B value); | 1482 void set f2(B value); |
| 1483 void set f3(B value); | 1483 void set f3(B value); |
| 1484 void set f4(B value); | 1484 void set f4(B value); |
| 1485 void set f5(B value); | 1485 void set f5(B value); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 class Child extends Base { | 1488 class Child extends Base { |
| 1489 void set f1(A value) {} | 1489 void set f1(A value) {} |
| 1490 /*severe:InvalidMethodOverride*/void set f2(C value) {} | 1490 /*severe:InvalidMethodOverride*/void set f2(C value) {} |
| 1491 /*severe:InvalidMethodOverride*/void set f3(value) {} | 1491 void set f3(value) {} |
| 1492 /*severe:InvalidMethodOverride*/void set f4(dynamic value) {} | 1492 /*severe:InvalidMethodOverride*/void set f4(dynamic value) {} |
| 1493 set f5(B value) {} | 1493 set f5(B value) {} |
| 1494 } | 1494 } |
| 1495 ''' | 1495 ''' |
| 1496 }); | 1496 }); |
| 1497 | 1497 |
| 1498 testChecker('field/setter override', { | 1498 testChecker('field/setter override', { |
| 1499 '/main.dart': ''' | 1499 '/main.dart': ''' |
| 1500 class A {} | 1500 class A {} |
| 1501 class B extends A {} | 1501 class B extends A {} |
| 1502 class C extends B {} | 1502 class C extends B {} |
| 1503 | 1503 |
| 1504 class Base { | 1504 class Base { |
| 1505 B f1; | 1505 B f1; |
| 1506 B f2; | 1506 B f2; |
| 1507 B f3; | 1507 B f3; |
| 1508 B f4; | 1508 B f4; |
| 1509 B f5; | 1509 B f5; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 class Child extends Base { | 1512 class Child extends Base { |
| 1513 B get f1 => null; | 1513 B get f1 => null; |
| 1514 B get f2 => null; | 1514 B get f2 => null; |
| 1515 B get f3 => null; | 1515 B get f3 => null; |
| 1516 B get f4 => null; | 1516 B get f4 => null; |
| 1517 B get f5 => null; | 1517 B get f5 => null; |
| 1518 | 1518 |
| 1519 void set f1(A value) {} | 1519 void set f1(A value) {} |
| 1520 /*severe:InvalidMethodOverride*/void set f2(C value) {} | 1520 /*severe:InvalidMethodOverride*/void set f2(C value) {} |
| 1521 /*severe:InvalidMethodOverride*/void set f3(value) {} | 1521 void set f3(value) {} |
| 1522 /*severe:InvalidMethodOverride*/void set f4(dynamic value) {} | 1522 /*severe:InvalidMethodOverride*/void set f4(dynamic value) {} |
| 1523 set f5(B value) {} | 1523 set f5(B value) {} |
| 1524 } | 1524 } |
| 1525 ''' | 1525 ''' |
| 1526 }); | 1526 }); |
| 1527 | 1527 |
| 1528 testChecker( | 1528 testChecker( |
| 1529 'method override', | 1529 'method override', |
| 1530 { | 1530 { |
| 1531 '/main.dart': ''' | 1531 '/main.dart': ''' |
| 1532 class A {} | 1532 class A {} |
| 1533 class B extends A {} | 1533 class B extends A {} |
| 1534 class C extends B {} | 1534 class C extends B {} |
| 1535 | 1535 |
| 1536 class Base { | 1536 class Base { |
| 1537 B m1(B a); | 1537 B m1(B a); |
| 1538 B m2(B a); | 1538 B m2(B a); |
| 1539 B m3(B a); | 1539 B m3(B a); |
| 1540 B m4(B a); | 1540 B m4(B a); |
| 1541 B m5(B a); | 1541 B m5(B a); |
| 1542 B m6(B a); | 1542 B m6(B a); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 class Child extends Base { | 1545 class Child extends Base { |
| 1546 /*severe:InvalidMethodOverride*/A m1(A value) {} | 1546 /*severe:InvalidMethodOverride*/A m1(A value) {} |
| 1547 /*severe:InvalidMethodOverride*/C m2(C value) {} | 1547 /*severe:InvalidMethodOverride*/C m2(C value) {} |
| 1548 /*severe:InvalidMethodOverride*/A m3(C value) {} | 1548 /*severe:InvalidMethodOverride*/A m3(C value) {} |
| 1549 C m4(A value) {} | 1549 C m4(A value) {} |
| 1550 /*severe:InvalidMethodOverride*/m5(value) {} | 1550 m5(value) {} |
| 1551 /*severe:InvalidMethodOverride*/dynamic m6(dynamic value) {} | 1551 /*severe:InvalidMethodOverride*/dynamic m6(dynamic value) {} |
| 1552 } | 1552 } |
| 1553 ''' | 1553 ''' |
| 1554 }, | 1554 }, |
| 1555 inferFromOverrides: true); | 1555 inferFromOverrides: true); |
| 1556 | 1556 |
| 1557 testChecker('unary operators', { | 1557 testChecker('unary operators', { |
| 1558 '/main.dart': ''' | 1558 '/main.dart': ''' |
| 1559 class A { | 1559 class A { |
| 1560 A operator ~() {} | 1560 A operator ~() {} |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 class I1 { | 2020 class I1 { |
| 2021 m(B a) {} | 2021 m(B a) {} |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 class T1 /*severe:InvalidMethodOverride*/extends Base | 2024 class T1 /*severe:InvalidMethodOverride*/extends Base |
| 2025 implements I1 {} | 2025 implements I1 {} |
| 2026 | 2026 |
| 2027 class T2 extends Base implements I1 { | 2027 class T2 extends Base implements I1 { |
| 2028 /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/m(a
) {} | 2028 /*severe:InvalidMethodOverride*/m(a) {} |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 class T3 extends Object with /*severe:InvalidMethodOverride*/Base | 2031 class T3 extends Object with /*severe:InvalidMethodOverride*/Base |
| 2032 implements I1 {} | 2032 implements I1 {} |
| 2033 | 2033 |
| 2034 class T4 extends Object with Base implements I1 { | 2034 class T4 extends Object with Base implements I1 { |
| 2035 /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/m(a
) {} | 2035 /*severe:InvalidMethodOverride*/m(a) {} |
| 2036 } | 2036 } |
| 2037 ''' | 2037 ''' |
| 2038 }); | 2038 }); |
| 2039 }); | 2039 }); |
| 2040 | 2040 |
| 2041 group('class override of grand interface', () { | 2041 group('class override of grand interface', () { |
| 2042 testChecker('interface of interface of child', { | 2042 testChecker('interface of interface of child', { |
| 2043 '/main.dart': ''' | 2043 '/main.dart': ''' |
| 2044 class A {} | 2044 class A {} |
| 2045 class B {} | 2045 class B {} |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2665 // Types other than int and double are not accepted. | 2665 // Types other than int and double are not accepted. |
| 2666 printInt( | 2666 printInt( |
| 2667 /*warning:DownCastImplicit*/min( | 2667 /*warning:DownCastImplicit*/min( |
| 2668 /*severe:StaticTypeError*/"hi", | 2668 /*severe:StaticTypeError*/"hi", |
| 2669 /*severe:StaticTypeError*/"there")); | 2669 /*severe:StaticTypeError*/"there")); |
| 2670 } | 2670 } |
| 2671 ''' | 2671 ''' |
| 2672 }); | 2672 }); |
| 2673 }); | 2673 }); |
| 2674 } | 2674 } |
| OLD | NEW |