| 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 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 class Base { | 1382 class Base { |
| 1383 B f1; | 1383 B f1; |
| 1384 B f2; | 1384 B f2; |
| 1385 B f3; | 1385 B f3; |
| 1386 B f4; | 1386 B f4; |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 class Child extends Base { | 1389 class Child extends Base { |
| 1390 /*severe:InvalidMethodOverride*/A f1; // invalid for getter | 1390 /*severe:InvalidMethodOverride*/A f1; // invalid for getter |
| 1391 /*severe:InvalidMethodOverride*/C f2; // invalid for setter | 1391 /*severe:InvalidMethodOverride*/C f2; // invalid for setter |
| 1392 /*severe:InferableOverride,severe:InvalidMethodOverride*/var f3; | 1392 /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/var f3; |
| 1393 /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/dynamic
f4; | 1393 /*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/dynamic
f4; |
| 1394 } | 1394 } |
| 1395 ''' | 1395 ''' |
| 1396 }, | 1396 }, |
| 1397 inferFromOverrides: false); | 1397 inferFromOverrides: false); |
| 1398 | 1398 |
| 1399 testChecker( | 1399 testChecker( |
| 1400 'getter/getter override', | 1400 'getter/getter override', |
| 1401 { | 1401 { |
| 1402 '/main.dart': ''' | 1402 '/main.dart': ''' |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1432 abstract class Base { | 1432 abstract class Base { |
| 1433 B get f1; | 1433 B get f1; |
| 1434 B get f2; | 1434 B get f2; |
| 1435 B get f3; | 1435 B get f3; |
| 1436 B get f4; | 1436 B get f4; |
| 1437 } | 1437 } |
| 1438 | 1438 |
| 1439 class Child extends Base { | 1439 class Child extends Base { |
| 1440 /*severe:InvalidMethodOverride*/A get f1 => null; | 1440 /*severe:InvalidMethodOverride*/A get f1 => null; |
| 1441 C get f2 => null; | 1441 C get f2 => null; |
| 1442 /*severe:InferableOverride*/get f3 => null; | 1442 /*severe:InvalidMethodOverride*/get f3 => null; |
| 1443 /*severe:InvalidMethodOverride*/dynamic get f4 => null; | 1443 /*severe:InvalidMethodOverride*/dynamic get f4 => null; |
| 1444 } | 1444 } |
| 1445 ''' | 1445 ''' |
| 1446 }, | 1446 }, |
| 1447 inferFromOverrides: false); | 1447 inferFromOverrides: false); |
| 1448 | 1448 |
| 1449 testChecker( | 1449 testChecker( |
| 1450 'field/getter override', | 1450 'field/getter override', |
| 1451 { | 1451 { |
| 1452 '/main.dart': ''' | 1452 '/main.dart': ''' |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2482 // This is a regression test: we used to report it twice because it was | 2482 // This is a regression test: we used to report it twice because it was |
| 2483 // the top super class and top super interface. | 2483 // the top super class and top super interface. |
| 2484 // TODO(sigmund): maybe we generalize this and don't report again errors | 2484 // TODO(sigmund): maybe we generalize this and don't report again errors |
| 2485 // when an interface is also a superclass. | 2485 // when an interface is also a superclass. |
| 2486 testChecker( | 2486 testChecker( |
| 2487 'no reporting of overrides with Object twice.', | 2487 'no reporting of overrides with Object twice.', |
| 2488 { | 2488 { |
| 2489 '/main.dart': ''' | 2489 '/main.dart': ''' |
| 2490 class A {} | 2490 class A {} |
| 2491 class T1 implements A { | 2491 class T1 implements A { |
| 2492 /*severe:InferableOverride*/toString() {} | 2492 /*severe:InvalidMethodOverride*/toString() {} |
| 2493 } | 2493 } |
| 2494 ''' | 2494 ''' |
| 2495 }, | 2495 }, |
| 2496 inferFromOverrides: false); | 2496 inferFromOverrides: false); |
| 2497 | 2497 |
| 2498 testChecker('invalid runtime checks', { | 2498 testChecker('invalid runtime checks', { |
| 2499 '/main.dart': ''' | 2499 '/main.dart': ''' |
| 2500 typedef int I2I(int x); | 2500 typedef int I2I(int x); |
| 2501 typedef int D2I(x); | 2501 typedef int D2I(x); |
| 2502 typedef int II2I(int x, int y); | 2502 typedef int II2I(int x, int y); |
| (...skipping 162 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 |