| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Regression test for dart2js that used to optimistically infer the |
| 6 // wrong types for fields because of generative constructors being |
| 7 // inlined. |
| 8 |
| 9 import "package:expect/expect.dart"; |
| 10 import "compiler_annotations.dart"; |
| 11 |
| 12 class A { |
| 13 var field; |
| 14 A(this.field); |
| 15 } |
| 16 |
| 17 var c = () => new List(42)[0]; |
| 18 |
| 19 main() { |
| 20 bar(); |
| 21 // Defeat type inferencing. |
| 22 new A(c()); |
| 23 doIt(); |
| 24 bar(); |
| 25 } |
| 26 |
| 27 @DontInline |
| 28 doIt() { |
| 29 () => 42; |
| 30 var c = new A(null); |
| 31 Expect.throws(() => c.field + 42, (e) => e is NoSuchMethodError); |
| 32 } |
| 33 |
| 34 @DontInline |
| 35 bar() { |
| 36 () => 42; |
| 37 return inlineLevel1(); |
| 38 } |
| 39 |
| 40 inlineLevel1() { |
| 41 return inlineLevel2(); |
| 42 } |
| 43 |
| 44 inlineLevel2() { |
| 45 return inlineLevel3(); |
| 46 } |
| 47 |
| 48 inlineLevel3() { |
| 49 return inlineLevel4(); |
| 50 } |
| 51 |
| 52 inlineLevel4() { |
| 53 return new A(42); |
| 54 } |
| OLD | NEW |