mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
2da0b9f4f1
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>
26 lines
762 B
Dart
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;
|
|
}
|