dart-sdk/tests/language_2/bailout2_test.dart
G?nter Z?chbauer 2da0b9f4f1 fix some typos
Closes #34738
https://github.com/dart-lang/sdk/pull/34738

GitOrigin-RevId: d211bbacfe65355cf7304c990ffb6c79d7a229cf
Change-Id: If690e6d378e543b300e1f6a353ceae73e39c29db
Reviewed-on: https://dart-review.googlesource.com/c/78900
Reviewed-by: Alexander Thomas <athom@google.com>
2018-10-10 19:15:30 +00:00

26 lines
762 B
Dart

// Copyright (c) 2012, 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.
import "package:expect/expect.dart";
var a;
main() {
// Write a loop to force a bailout method on [A.foo].
for (int i = 0; i < 10; i++) {
if (a != null) new A().foo([]);
Expect.equals(42, new A().foo(new A()));
}
}
class A {
// In dart2js, the optimized version of foo tries to optimize the
// uses of a.length (which is used two times here: for the index,
// and for the bounds check), and that optimization used to crash
// the compiler.
foo(a) => a[a.length];
int get length => 42;
operator [](index) => 42;
}