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

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

Issue 16533002: Fix 2/2 for bug https://code.google.com/p/dart/issues/detail?id=11117: when inlining a generative c… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 // Regression test for dart2js that used to optimistically infer the
6 // wrong types for fields because of generative constructors being
7 // inlined.
8
9 import "package:expect/expect.dart";
10 import "compiler_annotations.dart";
11
12 class A {
13 var foo;
14 var bar;
15
16 @DontInline
17 A() {
18 // Currently defeat inlining by using a closure.
19 bar = () => 42;
20 foo = 54;
21 }
22 A.inline();
23 }
24
25 main() {
26 // Make sure A's constructor is analyzed first by surrounding the
27 // body by two allocations.
28 new A();
29 bar();
30 new A();
31 }
32
33 class B {
34 var bar;
35 var closure;
36 @DontInline
37 B() {
38 // Currently defeat inlining by using a closure.
39 closure = () => 42;
40 bar = new A().foo;
41 }
42 }
43
44 @DontInline
45 bar() {
46 // Make sure B's constructor is analyzed first by surrounding the
47 // body by two allocations.
48 new B();
49 // Currently defeat inlining by using a closure.
50 Expect.throws(() => new A.inline().foo + 42, (e) => e is NoSuchMethodError);
51 codegenLast();
52 new B();
53 }
54
55 @DontInline
56 codegenLast() {
57 // This assignment currently defeats simple type inference, but not
58 // the optimistic inferrer.
59 new A().foo = new B().bar;
60 // Currently defeat inlining by using a closure.
61 new B().closure = () => 42;
62 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698