| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import | 6 import |
| 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 7 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
| 8 show TypeMask; | 8 show TypeMask; |
| 9 | 9 |
| 10 import 'compiler_helper.dart'; | 10 import 'compiler_helper.dart'; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 var c = topLevelGetter(); | 226 var c = topLevelGetter(); |
| 227 if (c != null && c is! bool && c is! int) { | 227 if (c != null && c is! bool && c is! int) { |
| 228 return 42; | 228 return 42; |
| 229 } else if (c is String) { | 229 } else if (c is String) { |
| 230 return c; | 230 return c; |
| 231 } else { | 231 } else { |
| 232 return 68; | 232 return 68; |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 testIf1(a) { |
| 237 var c = null; |
| 238 if (a) { |
| 239 c = 10; |
| 240 } else { |
| 241 } |
| 242 return c; |
| 243 } |
| 244 |
| 245 testIf2(a) { |
| 246 var c = null; |
| 247 if (a) { |
| 248 } else { |
| 249 c = 10; |
| 250 } |
| 251 return c; |
| 252 } |
| 253 |
| 236 returnAsString() { | 254 returnAsString() { |
| 237 return topLevelGetter() as String; | 255 return topLevelGetter() as String; |
| 238 } | 256 } |
| 239 | 257 |
| 240 returnIntAsNum() { | 258 returnIntAsNum() { |
| 241 return 0 as num; | 259 return 0 as num; |
| 242 } | 260 } |
| 243 | 261 |
| 244 typedef int Foo(); | 262 typedef int Foo(); |
| 245 | 263 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 testIsCheck11(topLevelGetter()); | 498 testIsCheck11(topLevelGetter()); |
| 481 testIsCheck12(topLevelGetter()); | 499 testIsCheck12(topLevelGetter()); |
| 482 testIsCheck13(topLevelGetter()); | 500 testIsCheck13(topLevelGetter()); |
| 483 testIsCheck14(topLevelGetter()); | 501 testIsCheck14(topLevelGetter()); |
| 484 testIsCheck15(topLevelGetter()); | 502 testIsCheck15(topLevelGetter()); |
| 485 testIsCheck16(topLevelGetter()); | 503 testIsCheck16(topLevelGetter()); |
| 486 testIsCheck17(topLevelGetter()); | 504 testIsCheck17(topLevelGetter()); |
| 487 testIsCheck18(topLevelGetter()); | 505 testIsCheck18(topLevelGetter()); |
| 488 testIsCheck19(topLevelGetter()); | 506 testIsCheck19(topLevelGetter()); |
| 489 testIsCheck20(); | 507 testIsCheck20(); |
| 508 testIf1(topLevelGetter()); |
| 509 testIf2(topLevelGetter()); |
| 490 returnAsString(); | 510 returnAsString(); |
| 491 returnIntAsNum(); | 511 returnIntAsNum(); |
| 492 returnAsTypedef(); | 512 returnAsTypedef(); |
| 493 returnTopLevelGetter(); | 513 returnTopLevelGetter(); |
| 494 testDeadCode(); | 514 testDeadCode(); |
| 495 testLabeledIf(); | 515 testLabeledIf(); |
| 496 testSwitch1(); | 516 testSwitch1(); |
| 497 testSwitch2(); | 517 testSwitch2(); |
| 498 testSwitch3(); | 518 testSwitch3(); |
| 499 testSwitch4(); | 519 testSwitch4(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 checkReturn('testIsCheck11', intType); | 597 checkReturn('testIsCheck11', intType); |
| 578 checkReturn('testIsCheck12', typesTask.dynamicType); | 598 checkReturn('testIsCheck12', typesTask.dynamicType); |
| 579 checkReturn('testIsCheck13', intType); | 599 checkReturn('testIsCheck13', intType); |
| 580 checkReturn('testIsCheck14', typesTask.dynamicType); | 600 checkReturn('testIsCheck14', typesTask.dynamicType); |
| 581 checkReturn('testIsCheck15', intType); | 601 checkReturn('testIsCheck15', intType); |
| 582 checkReturn('testIsCheck16', typesTask.dynamicType); | 602 checkReturn('testIsCheck16', typesTask.dynamicType); |
| 583 checkReturn('testIsCheck17', intType); | 603 checkReturn('testIsCheck17', intType); |
| 584 checkReturn('testIsCheck18', typesTask.dynamicType); | 604 checkReturn('testIsCheck18', typesTask.dynamicType); |
| 585 checkReturn('testIsCheck19', typesTask.dynamicType); | 605 checkReturn('testIsCheck19', typesTask.dynamicType); |
| 586 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); | 606 checkReturn('testIsCheck20', typesTask.dynamicType.nonNullable()); |
| 607 checkReturn('testIf1', typesTask.intType.nullable()); |
| 608 checkReturn('testIf2', typesTask.intType.nullable()); |
| 587 checkReturn('returnAsString', | 609 checkReturn('returnAsString', |
| 588 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); | 610 new TypeMask.subtype(compiler.stringClass.computeType(compiler))); |
| 589 checkReturn('returnIntAsNum', typesTask.intType); | 611 checkReturn('returnIntAsNum', typesTask.intType); |
| 590 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); | 612 checkReturn('returnAsTypedef', typesTask.functionType.nullable()); |
| 591 checkReturn('returnTopLevelGetter', typesTask.intType); | 613 checkReturn('returnTopLevelGetter', typesTask.intType); |
| 592 checkReturn('testDeadCode', typesTask.intType); | 614 checkReturn('testDeadCode', typesTask.intType); |
| 593 checkReturn('testLabeledIf', typesTask.intType.nullable()); | 615 checkReturn('testLabeledIf', typesTask.intType.nullable()); |
| 594 checkReturn('testSwitch1', typesTask.intType | 616 checkReturn('testSwitch1', typesTask.intType |
| 595 .union(typesTask.doubleType, compiler).nullable().simplify(compiler)); | 617 .union(typesTask.doubleType, compiler).nullable().simplify(compiler)); |
| 596 checkReturn('testSwitch2', typesTask.intType); | 618 checkReturn('testSwitch2', typesTask.intType); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 checkReturnInClass('B', 'returnInt9', typesTask.intType); | 659 checkReturnInClass('B', 'returnInt9', typesTask.intType); |
| 638 | 660 |
| 639 checkFactoryConstructor(String className, String factoryName) { | 661 checkFactoryConstructor(String className, String factoryName) { |
| 640 var cls = findElement(compiler, className); | 662 var cls = findElement(compiler, className); |
| 641 var element = cls.localLookup(buildSourceString(factoryName)); | 663 var element = cls.localLookup(buildSourceString(factoryName)); |
| 642 Expect.equals(new TypeMask.nonNullExact(cls.rawType), | 664 Expect.equals(new TypeMask.nonNullExact(cls.rawType), |
| 643 typesInferrer.getReturnTypeOfElement(element)); | 665 typesInferrer.getReturnTypeOfElement(element)); |
| 644 } | 666 } |
| 645 checkFactoryConstructor('A', ''); | 667 checkFactoryConstructor('A', ''); |
| 646 } | 668 } |
| OLD | NEW |