| 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 void main() { | 484 void main() { |
| 485 Uri uri = new Uri(scheme: 'source'); | 485 Uri uri = new Uri(scheme: 'source'); |
| 486 var compiler = compilerFor(TEST, uri); | 486 var compiler = compilerFor(TEST, uri); |
| 487 compiler.runCompiler(uri); | 487 compiler.runCompiler(uri); |
| 488 var typesInferrer = compiler.typesTask.typesInferrer; | 488 var typesInferrer = compiler.typesTask.typesInferrer; |
| 489 | 489 |
| 490 checkReturn(String name, type) { | 490 checkReturn(String name, type) { |
| 491 var element = findElement(compiler, name); | 491 var element = findElement(compiler, name); |
| 492 Expect.equals( | 492 Expect.equals( |
| 493 type, | 493 type, |
| 494 typesInferrer.internal.returnTypeOf[element].simplify(compiler), | 494 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), |
| 495 name); | 495 name); |
| 496 } | 496 } |
| 497 var interceptorType = | 497 var interceptorType = |
| 498 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 498 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 499 | 499 |
| 500 checkReturn('returnNum1', typesInferrer.numType); | 500 checkReturn('returnNum1', typesInferrer.numType); |
| 501 checkReturn('returnNum2', typesInferrer.numType); | 501 checkReturn('returnNum2', typesInferrer.numType); |
| 502 checkReturn('returnInt1', typesInferrer.intType); | 502 checkReturn('returnInt1', typesInferrer.intType); |
| 503 checkReturn('returnInt2', typesInferrer.intType); | 503 checkReturn('returnInt2', typesInferrer.intType); |
| 504 checkReturn('returnDouble', typesInferrer.doubleType); | 504 checkReturn('returnDouble', typesInferrer.doubleType); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 checkReturn('testBreak2', typesInferrer.intType.nullable()); | 552 checkReturn('testBreak2', typesInferrer.intType.nullable()); |
| 553 checkReturn('testReturnElementOfConstList1', typesInferrer.intType); | 553 checkReturn('testReturnElementOfConstList1', typesInferrer.intType); |
| 554 checkReturn('testReturnElementOfConstList2', typesInferrer.intType); | 554 checkReturn('testReturnElementOfConstList2', typesInferrer.intType); |
| 555 checkReturn('testReturnItselfOrInt', typesInferrer.intType); | 555 checkReturn('testReturnItselfOrInt', typesInferrer.intType); |
| 556 checkReturn('testReturnInvokeDynamicGetter', typesInferrer.dynamicType); | 556 checkReturn('testReturnInvokeDynamicGetter', typesInferrer.dynamicType); |
| 557 | 557 |
| 558 checkReturnInClass(String className, String methodName, type) { | 558 checkReturnInClass(String className, String methodName, type) { |
| 559 var cls = findElement(compiler, className); | 559 var cls = findElement(compiler, className); |
| 560 var element = cls.lookupLocalMember(buildSourceString(methodName)); | 560 var element = cls.lookupLocalMember(buildSourceString(methodName)); |
| 561 Expect.equals(type, | 561 Expect.equals(type, |
| 562 typesInferrer.internal.returnTypeOf[element].simplify(compiler)); | 562 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
| 563 } | 563 } |
| 564 | 564 |
| 565 checkReturnInClass('A', 'returnInt1', typesInferrer.intType); | 565 checkReturnInClass('A', 'returnInt1', typesInferrer.intType); |
| 566 checkReturnInClass('A', 'returnInt2', typesInferrer.intType); | 566 checkReturnInClass('A', 'returnInt2', typesInferrer.intType); |
| 567 checkReturnInClass('A', 'returnInt3', typesInferrer.intType); | 567 checkReturnInClass('A', 'returnInt3', typesInferrer.intType); |
| 568 checkReturnInClass('A', 'returnInt4', typesInferrer.intType); | 568 checkReturnInClass('A', 'returnInt4', typesInferrer.intType); |
| 569 checkReturnInClass('A', 'returnInt5', typesInferrer.intType); | 569 checkReturnInClass('A', 'returnInt5', typesInferrer.intType); |
| 570 checkReturnInClass('A', 'returnInt6', typesInferrer.intType); | 570 checkReturnInClass('A', 'returnInt6', typesInferrer.intType); |
| 571 checkReturnInClass('A', '==', interceptorType); | 571 checkReturnInClass('A', '==', interceptorType); |
| 572 | 572 |
| 573 checkReturnInClass('B', 'returnInt1', typesInferrer.intType); | 573 checkReturnInClass('B', 'returnInt1', typesInferrer.intType); |
| 574 checkReturnInClass('B', 'returnInt2', typesInferrer.intType); | 574 checkReturnInClass('B', 'returnInt2', typesInferrer.intType); |
| 575 checkReturnInClass('B', 'returnInt3', typesInferrer.intType); | 575 checkReturnInClass('B', 'returnInt3', typesInferrer.intType); |
| 576 checkReturnInClass('B', 'returnInt4', typesInferrer.intType); | 576 checkReturnInClass('B', 'returnInt4', typesInferrer.intType); |
| 577 checkReturnInClass('B', 'returnInt5', typesInferrer.intType); | 577 checkReturnInClass('B', 'returnInt5', typesInferrer.intType); |
| 578 checkReturnInClass('B', 'returnInt6', typesInferrer.intType); | 578 checkReturnInClass('B', 'returnInt6', typesInferrer.intType); |
| 579 checkReturnInClass('B', 'returnInt7', typesInferrer.intType); | 579 checkReturnInClass('B', 'returnInt7', typesInferrer.intType); |
| 580 checkReturnInClass('B', 'returnInt8', typesInferrer.intType); | 580 checkReturnInClass('B', 'returnInt8', typesInferrer.intType); |
| 581 checkReturnInClass('B', 'returnInt9', typesInferrer.intType); | 581 checkReturnInClass('B', 'returnInt9', typesInferrer.intType); |
| 582 | 582 |
| 583 checkFactoryConstructor(String className) { | 583 checkFactoryConstructor(String className) { |
| 584 var cls = findElement(compiler, className); | 584 var cls = findElement(compiler, className); |
| 585 var element = cls.localLookup(buildSourceString(className)); | 585 var element = cls.localLookup(buildSourceString(className)); |
| 586 Expect.equals(new TypeMask.nonNullExact(cls.rawType), | 586 Expect.equals(new TypeMask.nonNullExact(cls.rawType), |
| 587 typesInferrer.internal.returnTypeOf[element]); | 587 typesInferrer.getReturnTypeOfElement(element)); |
| 588 } | 588 } |
| 589 checkFactoryConstructor('A'); | 589 checkFactoryConstructor('A'); |
| 590 } | 590 } |
| OLD | NEW |