| 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 'compiler_helper.dart'; | 6 import 'compiler_helper.dart'; |
| 7 import 'parser_helper.dart'; | 7 import 'parser_helper.dart'; |
| 8 | 8 |
| 9 const String TEST = """ | 9 const String TEST = """ |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 void main() { | 63 void main() { |
| 64 Uri uri = new Uri.fromComponents(scheme: 'source'); | 64 Uri uri = new Uri.fromComponents(scheme: 'source'); |
| 65 var compiler = compilerFor(TEST, uri); | 65 var compiler = compilerFor(TEST, uri); |
| 66 compiler.runCompiler(uri); | 66 compiler.runCompiler(uri); |
| 67 var typesInferrer = compiler.typesTask.typesInferrer; | 67 var typesInferrer = compiler.typesTask.typesInferrer; |
| 68 | 68 |
| 69 checkReturnInClass(String className, String methodName, type) { | 69 checkReturnInClass(String className, String methodName, type) { |
| 70 var cls = findElement(compiler, className); | 70 var cls = findElement(compiler, className); |
| 71 var element = cls.lookupLocalMember(buildSourceString(methodName)); | 71 var element = cls.lookupLocalMember(buildSourceString(methodName)); |
| 72 Expect.equals(type, typesInferrer.internal.returnTypeOf[element]); | 72 Expect.equals(type, |
| 73 typesInferrer.internal.returnTypeOf[element].simplify(compiler)); |
| 73 } | 74 } |
| 74 | 75 |
| 75 var subclassOfInterceptor = | 76 var subclassOfInterceptor = |
| 76 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 77 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 77 | 78 |
| 78 checkReturnInClass('A', 'returnNum1', typesInferrer.numType); | 79 checkReturnInClass('A', 'returnNum1', typesInferrer.numType); |
| 79 checkReturnInClass('A', 'returnNum2', typesInferrer.numType); | 80 checkReturnInClass('A', 'returnNum2', typesInferrer.numType); |
| 80 checkReturnInClass('A', 'returnNum3', typesInferrer.numType); | 81 checkReturnInClass('A', 'returnNum3', typesInferrer.numType); |
| 81 checkReturnInClass('A', 'returnNum4', typesInferrer.numType); | 82 checkReturnInClass('A', 'returnNum4', typesInferrer.numType); |
| 82 checkReturnInClass('A', 'returnNum5', typesInferrer.numType); | 83 checkReturnInClass('A', 'returnNum5', typesInferrer.numType); |
| 83 checkReturnInClass('A', 'returnNum6', typesInferrer.numType); | 84 checkReturnInClass('A', 'returnNum6', typesInferrer.numType); |
| 84 checkReturnInClass('A', 'returnDynamic1', subclassOfInterceptor); | 85 checkReturnInClass('A', 'returnDynamic1', subclassOfInterceptor); |
| 85 checkReturnInClass('A', 'returnDynamic2', subclassOfInterceptor); | 86 checkReturnInClass('A', 'returnDynamic2', subclassOfInterceptor); |
| 86 checkReturnInClass('A', 'returnDynamic3', typesInferrer.dynamicType); | 87 checkReturnInClass('A', 'returnDynamic3', typesInferrer.dynamicType); |
| 87 | 88 |
| 88 checkReturnInClass('B', 'returnString1', typesInferrer.stringType); | 89 checkReturnInClass('B', 'returnString1', typesInferrer.stringType); |
| 89 checkReturnInClass('B', 'returnString2', typesInferrer.stringType); | 90 checkReturnInClass('B', 'returnString2', typesInferrer.stringType); |
| 90 checkReturnInClass('B', 'returnDynamic1', typesInferrer.dynamicType); | 91 checkReturnInClass('B', 'returnDynamic1', typesInferrer.dynamicType); |
| 91 checkReturnInClass('B', 'returnDynamic2', typesInferrer.dynamicType); | 92 checkReturnInClass('B', 'returnDynamic2', typesInferrer.dynamicType); |
| 92 checkReturnInClass('B', 'returnDynamic3', typesInferrer.dynamicType); | 93 checkReturnInClass('B', 'returnDynamic3', typesInferrer.dynamicType); |
| 93 checkReturnInClass('B', 'returnDynamic4', typesInferrer.dynamicType); | 94 checkReturnInClass('B', 'returnDynamic4', typesInferrer.dynamicType); |
| 94 } | 95 } |
| OLD | NEW |