mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 13:22:01 +00:00
2dcd56ef43
There are far too many files here to review everyone carefully. Spot checking most of the diffs look good as test code is generally written with less care than application code so lots of ugly formatting get through. If people notice files where the automated formatting bothers them feel free to comment indicating file names and I'll move spaces within comments to make the formatting cleaner and use comments to force block formatting as I have done for other case where formatting looked bad. BUG= R=efortuna@google.com Review-Url: https://codereview.chromium.org/2771453003 .
54 lines
1.6 KiB
Dart
54 lines
1.6 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Regression test for dart2js code generation in checked mode. See
|
|
// last part of https://code.google.com/p/dart/issues/detail?id=9687.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class A {
|
|
final finalField;
|
|
final otherFinalField;
|
|
|
|
A()
|
|
: finalField = 42,
|
|
otherFinalField = 54;
|
|
|
|
expectFinalField(arg1, arg2) {
|
|
Expect.equals(arg1, arg2);
|
|
Expect.equals(finalField, arg1);
|
|
}
|
|
|
|
expectOtherFinalField(_, arg1, arg2) {
|
|
Expect.equals(arg1, arg2);
|
|
Expect.equals(otherFinalField, arg1);
|
|
}
|
|
}
|
|
|
|
var array = [new A()];
|
|
|
|
main() {
|
|
// [untypedReceiver] is made so that the compiler does not know
|
|
// what it is.
|
|
var untypedReceiver = array[0];
|
|
|
|
// [typedReceiver] is made so that the compiler knows what it is.
|
|
var typedReceiver = new A();
|
|
|
|
// Using [: finalField :] twice will make the compiler want to
|
|
// allocate one temporary for it.
|
|
var a = untypedReceiver.expectFinalField(
|
|
typedReceiver.finalField, typedReceiver.finalField);
|
|
|
|
// Having a check instruction in between two allocations of
|
|
// temporary variables used to trigger a bug in the compiler.
|
|
int b = a;
|
|
|
|
// Using [: otherFinalField :] twice will make the compiler want to
|
|
// allocate one temporary for it. The compiler used to assign the
|
|
// same temporary for [: otherFinalField :] and [: finalField :].
|
|
untypedReceiver.expectOtherFinalField(
|
|
b, typedReceiver.otherFinalField, typedReceiver.otherFinalField);
|
|
}
|