| 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 import "package:expect/expect.dart"; |
| 6 import "compiler_annotations.dart"; |
| 7 |
| 8 var a = [null]; |
| 9 |
| 10 class A { |
| 11 var foo; |
| 12 var bar; |
| 13 |
| 14 @DontInline |
| 15 A() { |
| 16 // Currently defeat inlining by using a closure. |
| 17 bar = () => 42; |
| 18 foo = 42; |
| 19 foo = a[0]; |
| 20 } |
| 21 } |
| 22 |
| 23 class B { |
| 24 var foo; |
| 25 var bar; |
| 26 |
| 27 @DontInline |
| 28 B() { |
| 29 // Currently defeat inlining by using a closure. |
| 30 bar = () => 42; |
| 31 foo = 42; |
| 32 foo = a[0]; |
| 33 if (false) foo = 42; |
| 34 } |
| 35 } |
| 36 |
| 37 main() { |
| 38 // Surround the call to [bar] by allocations of [A] and [B] to |
| 39 // ensure their constructors get analyzed first. |
| 40 new A(); |
| 41 new B(); |
| 42 bar(); |
| 43 new A(); |
| 44 new B(); |
| 45 } |
| 46 |
| 47 @DontInline |
| 48 bar() { |
| 49 // Currently defeat inlining by using a closure. |
| 50 Expect.throws(() => new A().foo + 42, (e) => e is NoSuchMethodError); |
| 51 Expect.throws(() => new B().foo + 42, (e) => e is NoSuchMethodError); |
| 52 } |
| OLD | NEW |