| 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 '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' | 6 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart' |
| 7 show TypeMask; | 7 show TypeMask; |
| 8 | 8 |
| 9 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 10 | 10 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 returnDyn6() { | 130 returnDyn6() { |
| 131 try { | 131 try { |
| 132 throw 42; | 132 throw 42; |
| 133 } catch (e) { | 133 } catch (e) { |
| 134 return e; | 134 return e; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 returnInt7() { |
| 139 var a = 'foo'; |
| 140 try { |
| 141 a = 42; |
| 142 return a; |
| 143 } catch (e) { |
| 144 } |
| 145 return 2; |
| 146 } |
| 138 | 147 |
| 139 main() { | 148 main() { |
| 140 returnInt1(); | 149 returnInt1(); |
| 141 returnDyn1(); | 150 returnDyn1(); |
| 142 returnInt2(); | 151 returnInt2(); |
| 143 returnDyn2(); | 152 returnDyn2(); |
| 144 returnInt3(); | 153 returnInt3(); |
| 145 returnDyn3(); | 154 returnDyn3(); |
| 146 returnInt4(); | 155 returnInt4(); |
| 147 returnDyn4(); | 156 returnDyn4(); |
| 148 returnInt5(); | 157 returnInt5(); |
| 149 returnDyn5(); | 158 returnDyn5(); |
| 150 returnInt6(); | 159 returnInt6(); |
| 151 returnDyn6(); | 160 returnDyn6(); |
| 161 returnInt7(); |
| 152 } | 162 } |
| 153 """; | 163 """; |
| 154 | 164 |
| 155 | 165 |
| 156 void main() { | 166 void main() { |
| 157 Uri uri = new Uri(scheme: 'source'); | 167 Uri uri = new Uri(scheme: 'source'); |
| 158 var compiler = compilerFor(TEST, uri); | 168 var compiler = compilerFor(TEST, uri); |
| 159 compiler.runCompiler(uri); | 169 compiler.runCompiler(uri); |
| 160 var typesTask = compiler.typesTask; | 170 var typesTask = compiler.typesTask; |
| 161 var typesInferrer = typesTask.typesInferrer; | 171 var typesInferrer = typesTask.typesInferrer; |
| 162 | 172 |
| 163 checkReturn(String name, type) { | 173 checkReturn(String name, type) { |
| 164 var element = findElement(compiler, name); | 174 var element = findElement(compiler, name); |
| 165 Expect.equals(type, | 175 Expect.equals(type, |
| 166 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); | 176 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); |
| 167 } | 177 } |
| 168 | 178 |
| 169 checkReturn('returnInt1', typesTask.intType); | 179 checkReturn('returnInt1', typesTask.intType); |
| 170 checkReturn('returnInt2', typesTask.intType); | 180 checkReturn('returnInt2', typesTask.intType); |
| 171 checkReturn('returnInt3', typesTask.intType); | 181 checkReturn('returnInt3', typesTask.intType); |
| 172 checkReturn('returnInt4', typesTask.intType); | 182 checkReturn('returnInt4', typesTask.intType); |
| 173 checkReturn('returnInt5', typesTask.intType); | 183 checkReturn('returnInt5', typesTask.intType); |
| 174 checkReturn('returnInt6', | 184 checkReturn('returnInt6', |
| 175 new TypeMask.nonNullSubtype(compiler.intClass.rawType)); | 185 new TypeMask.nonNullSubtype(compiler.intClass.rawType)); |
| 186 checkReturn('returnInt7', typesTask.intType); |
| 176 | 187 |
| 177 var subclassOfInterceptor = | 188 var subclassOfInterceptor = |
| 178 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 189 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 179 | 190 |
| 180 checkReturn('returnDyn1', subclassOfInterceptor); | 191 checkReturn('returnDyn1', subclassOfInterceptor); |
| 181 checkReturn('returnDyn2', subclassOfInterceptor); | 192 checkReturn('returnDyn2', subclassOfInterceptor); |
| 182 checkReturn('returnDyn3', subclassOfInterceptor); | 193 checkReturn('returnDyn3', subclassOfInterceptor); |
| 183 checkReturn('returnDyn4', subclassOfInterceptor); | 194 checkReturn('returnDyn4', subclassOfInterceptor); |
| 184 checkReturn('returnDyn5', subclassOfInterceptor); | 195 checkReturn('returnDyn5', subclassOfInterceptor); |
| 185 checkReturn('returnDyn6', typesTask.dynamicType); | 196 checkReturn('returnDyn6', typesTask.dynamicType); |
| 186 } | 197 } |
| OLD | NEW |