| 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 crash during the |
| 6 // [SsaCodeMotion] phase on this code. |
| 7 |
| 8 class A { |
| 9 final finalField; |
| 10 var field = 2; |
| 11 foo() { |
| 12 new A().field = 42; |
| 13 } |
| 14 A._() : finalField = 42; |
| 15 A() : finalField = [new A._(), new B(), new Object()][1]; |
| 16 } |
| 17 |
| 18 class B { |
| 19 foo() {} |
| 20 bar() {} |
| 21 } |
| 22 |
| 23 main() { |
| 24 var a = new A(); |
| 25 // Create a new block for SsaCodeMotion: the phase will want to move |
| 26 // field access on [a] to this block. |
| 27 if (true) { |
| 28 var b = a.finalField; |
| 29 var d = a.field; |
| 30 b.bar(); |
| 31 |
| 32 // [c] gets GVN'ed with [b]. As a consequence, the type propagator |
| 33 // that runs after GVN sees that [c] can only be a [B] because of |
| 34 // the call to [bar]. |
| 35 var c = a.finalField; |
| 36 c.foo(); |
| 37 |
| 38 // [e] does not get GVN'ed because the GVN phase sees [c.foo()] as |
| 39 // having side effects. |
| 40 var e = a.field; |
| 41 if (d + e != 4) throw 'Test failed'; |
| 42 } |
| 43 } |
| OLD | NEW |