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