blob: 48ee8b9b52c1833b32f0a8208a539819e227b064 [file] [log] [blame]
// 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.
// @dart = 2.9
import "package:expect/expect.dart";
import "../compiler_annotations.dart";
var a = [null];
class A {
var foo;
var bar;
@DontInline()
A() {
// Currently defeat inlining by using a closure.
bar = () => 42;
foo = 42;
foo = a[0];
}
}
class B {
var foo;
var bar;
@DontInline()
B() {
// Currently defeat inlining by using a closure.
bar = () => 42;
foo = 42;
foo = a[0];
if (false) foo = 42;
}
}
main() {
// Surround the call to [bar] by allocations of [A] and [B] to
// ensure their constructors get analyzed first.
new A();
new B();
bar();
new A();
new B();
}
@DontInline()
bar() {
// Currently defeat inlining by using a closure.
Expect.throwsNoSuchMethodError(() => new A().foo + 42);
Expect.throwsNoSuchMethodError(() => new B().foo + 42);
}