Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: tests/language/inferrer_constructor2_test.dart

Issue 22999005: Make analyzer happy and use annotations the right way. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/inferrer_constructor3_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Regression test for dart2js that used to optimistically infer the 5 // Regression test for dart2js that used to optimistically infer the
6 // wrong types for fields because of generative constructors being 6 // wrong types for fields because of generative constructors being
7 // inlined. 7 // inlined.
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "compiler_annotations.dart"; 10 import "compiler_annotations.dart";
11 11
12 class A { 12 class A {
13 var foo; 13 var foo;
14 var bar; 14 var bar;
15 15
16 @DontInline 16 @DontInline()
17 A() { 17 A() {
18 // Currently defeat inlining by using a closure. 18 // Currently defeat inlining by using a closure.
19 bar = () => 42; 19 bar = () => 42;
20 foo = 54; 20 foo = 54;
21 } 21 }
22 A.inline(); 22 A.inline();
23 } 23 }
24 24
25 main() { 25 main() {
26 // Make sure A's constructor is analyzed first by surrounding the 26 // Make sure A's constructor is analyzed first by surrounding the
27 // body by two allocations. 27 // body by two allocations.
28 new A(); 28 new A();
29 bar(); 29 bar();
30 new A(); 30 new A();
31 } 31 }
32 32
33 class B { 33 class B {
34 var bar; 34 var bar;
35 var closure; 35 var closure;
36 @DontInline 36 @DontInline()
37 B() { 37 B() {
38 // Currently defeat inlining by using a closure. 38 // Currently defeat inlining by using a closure.
39 closure = () => 42; 39 closure = () => 42;
40 bar = new A().foo; 40 bar = new A().foo;
41 } 41 }
42 } 42 }
43 43
44 @DontInline 44 @DontInline()
45 bar() { 45 bar() {
46 // Make sure B's constructor is analyzed first by surrounding the 46 // Make sure B's constructor is analyzed first by surrounding the
47 // body by two allocations. 47 // body by two allocations.
48 new B(); 48 new B();
49 // Currently defeat inlining by using a closure. 49 // Currently defeat inlining by using a closure.
50 Expect.throws(() => new A.inline().foo + 42, (e) => e is NoSuchMethodError); 50 Expect.throws(() => new A.inline().foo + 42, (e) => e is NoSuchMethodError);
51 codegenLast(); 51 codegenLast();
52 new B(); 52 new B();
53 } 53 }
54 54
55 @DontInline 55 @DontInline()
56 codegenLast() { 56 codegenLast() {
57 // This assignment currently defeats simple type inference, but not 57 // This assignment currently defeats simple type inference, but not
58 // the optimistic inferrer. 58 // the optimistic inferrer.
59 new A().foo = new B().bar; 59 new A().foo = new B().bar;
60 // Currently defeat inlining by using a closure. 60 // Currently defeat inlining by using a closure.
61 new B().closure = () => 42; 61 new B().closure = () => 42;
62 } 62 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/inferrer_constructor3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698