| 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 code generation in checked mode. See |
| 6 // last part of https://code.google.com/p/dart/issues/detail?id=9687. |
| 7 |
| 8 import "package:expect/expect.dart"; |
| 9 |
| 10 class A { |
| 11 final finalField; |
| 12 final otherFinalField; |
| 13 |
| 14 A() : finalField = 42, otherFinalField = 54; |
| 15 |
| 16 expectFinalField(arg1, arg2) { |
| 17 Expect.equals(arg1, arg2); |
| 18 Expect.equals(finalField, arg1); |
| 19 } |
| 20 |
| 21 expectOtherFinalField(_, arg1, arg2) { |
| 22 Expect.equals(arg1, arg2); |
| 23 Expect.equals(otherFinalField, arg1); |
| 24 } |
| 25 } |
| 26 |
| 27 var array = [new A()]; |
| 28 |
| 29 main() { |
| 30 // [untypedReceiver] is made so that the compiler does not know |
| 31 // what it is. |
| 32 var untypedReceiver = array[0]; |
| 33 |
| 34 // [typedReceiver] is made so that the compiler knows what it is. |
| 35 var typedReceiver = new A(); |
| 36 |
| 37 // Using [: finalField :] twice will make the compiler want to |
| 38 // allocate one temporary for it. |
| 39 var a = untypedReceiver.expectFinalField( |
| 40 typedReceiver.finalField, typedReceiver.finalField); |
| 41 |
| 42 // Having a check instruction in between two allocations of |
| 43 // temporary variables used to trigger a bug in the compiler. |
| 44 int b = a; |
| 45 |
| 46 // Using [: otherFinalField :] twice will make the compiler want to |
| 47 // allocate one temporary for it. The compiler used to assign the |
| 48 // same temporary for [: otherFinalField :] and [: finalField :]. |
| 49 untypedReceiver.expectOtherFinalField( |
| 50 b, typedReceiver.otherFinalField, typedReceiver.otherFinalField); |
| 51 } |
| OLD | NEW |