| 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 "package:async_helper/async_helper.dart"; | 6 import "package:async_helper/async_helper.dart"; |
| 7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
| 8 import 'type_mask_test_helper.dart'; | 8 import 'type_mask_test_helper.dart'; |
| 9 | 9 |
| 10 const String TEST = """ | 10 const String TEST = """ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 returnDyn7b(x) => x; | 48 returnDyn7b(x) => x; |
| 49 | 49 |
| 50 returnDyn7() { | 50 returnDyn7() { |
| 51 var a = "foo"; | 51 var a = "foo"; |
| 52 if (a.length == 3) a = 52; | 52 if (a.length == 3) a = 52; |
| 53 if ((a is int) || (a is String && true)) returnDyn7b(a); | 53 if ((a is int) || (a is String && true)) returnDyn7b(a); |
| 54 return a; | 54 return a; |
| 55 } | 55 } |
| 56 | 56 |
| 57 returnDyn8(x) => x; |
| 58 |
| 59 test8() { |
| 60 var a = "foo"; |
| 61 if (a.length == 3) a = 52; |
| 62 if ((false && a is! String) || returnDyn8(a)) return a; |
| 63 return a; |
| 64 } |
| 65 |
| 57 main() { | 66 main() { |
| 58 returnDyn1(); | 67 returnDyn1(); |
| 59 returnDyn2(); | 68 returnDyn2(); |
| 60 returnDyn3(); | 69 returnDyn3(); |
| 61 returnDyn4(); | 70 returnDyn4(); |
| 62 returnDyn5(); | 71 returnDyn5(); |
| 63 returnDyn6(); | 72 returnDyn6(); |
| 64 returnDyn7(); | 73 returnDyn7(); |
| 74 test8(); |
| 65 } | 75 } |
| 66 """; | 76 """; |
| 67 | 77 |
| 68 | 78 |
| 69 void main() { | 79 void main() { |
| 70 Uri uri = new Uri(scheme: 'source'); | 80 Uri uri = new Uri(scheme: 'source'); |
| 71 var compiler = compilerFor(TEST, uri); | 81 var compiler = compilerFor(TEST, uri); |
| 72 asyncTest(() => compiler.runCompiler(uri).then((_) { | 82 asyncTest(() => compiler.runCompiler(uri).then((_) { |
| 73 var typesInferrer = compiler.typesTask.typesInferrer; | 83 var typesInferrer = compiler.typesTask.typesInferrer; |
| 74 | 84 |
| 75 checkReturn(String name, type) { | 85 checkReturn(String name, type) { |
| 76 var element = findElement(compiler, name); | 86 var element = findElement(compiler, name); |
| 77 Expect.equals(type, | 87 Expect.equals(type, |
| 78 simplify(typesInferrer.getReturnTypeOfElement(element), compiler)); | 88 simplify(typesInferrer.getReturnTypeOfElement(element), compiler)); |
| 79 } | 89 } |
| 80 | 90 |
| 81 var subclassOfInterceptor = | 91 var subclassOfInterceptor = |
| 82 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); | 92 findTypeMask(compiler, 'Interceptor', 'nonNullSubclass'); |
| 83 | 93 |
| 84 checkReturn('returnDyn1', subclassOfInterceptor); | 94 checkReturn('returnDyn1', subclassOfInterceptor); |
| 85 checkReturn('returnDyn2', subclassOfInterceptor); | 95 checkReturn('returnDyn2', subclassOfInterceptor); |
| 86 checkReturn('returnDyn3', subclassOfInterceptor); | 96 checkReturn('returnDyn3', subclassOfInterceptor); |
| 87 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); | 97 checkReturn('returnDyn4', compiler.typesTask.dynamicType.nonNullable()); |
| 88 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); | 98 checkReturn('returnDyn5', compiler.typesTask.dynamicType.nonNullable()); |
| 89 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); | 99 checkReturn('returnDyn6', compiler.typesTask.dynamicType.nonNullable()); |
| 90 checkReturn('returnDyn7', subclassOfInterceptor); | 100 checkReturn('returnDyn7', subclassOfInterceptor); |
| 91 checkReturn('returnDyn7b', subclassOfInterceptor); | 101 checkReturn('returnDyn7b', subclassOfInterceptor); |
| 102 checkReturn('returnDyn8', subclassOfInterceptor); |
| 92 })); | 103 })); |
| 93 } | 104 } |
| OLD | NEW |