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

Side by Side Diff: tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart

Issue 1020853007: Don't bailout of type inference for simple NSM implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
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 import 'package:expect/expect.dart'; 5 import 'package:expect/expect.dart';
6 6
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'compiler_helper.dart'; 8 import 'compiler_helper.dart';
9 import 'package:compiler/src/types/types.dart';
9 import 'parser_helper.dart'; 10 import 'parser_helper.dart';
10 import 'type_mask_test_helper.dart'; 11 import 'type_mask_test_helper.dart';
11 12
12 const String TEST1 = """ 13 const String TEST1 = """
13 class A { 14 class A {
14 noSuchMethod(im) => 42; 15 noSuchMethod(im) => 42;
15 } 16 }
16 17
17 class B extends A { 18 class B extends A {
18 foo(); 19 foo();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 test5(); 88 test5();
88 test6(); 89 test6();
89 test7(); 90 test7();
90 test8(); 91 test8();
91 test9(); 92 test9();
92 test10(); 93 test10();
93 test11(); 94 test11();
94 } 95 }
95 """; 96 """;
96 97
98 const String TEST3 = """
99 class A {
100 // We may ignore this for type inference because syntactically it always
101 // throws an exception.
102 noSuchMethod(im) => throw 'foo';
103 }
104
105 class B extends A {
106 foo() => {};
107 }
108
109 class C extends B {
110 foo() => {};
111 }
112
113 var a = [new B(), new C()][0];
114 test1() => new A().foo();
115 test2() => a.foo();
116 test3() => new B().foo();
117 test4() => new C().foo();
118 test5() => (a ? new A() : new B()).foo();
119 test6() => (a ? new B() : new C()).foo();
120
121 main() {
122 test1();
123 test2();
124 test3();
125 test4();
126 test5();
127 test6();
128 }
129 """;
130
131 const String TEST4 = """
132 class A {
133 // We may ignore this for type inference because it forwards to a default
134 // noSuchMethod implementation, which always throws an exception.
135 noSuchMethod(im) => super.noSuchMethod(im);
136 }
137
138 class B extends A {
139 foo() => {};
140 }
141
142 class C extends B {
143 foo() => {};
144 }
145
146 var a = [new B(), new C()][0];
147 test1() => new A().foo();
148 test2() => a.foo();
149 test3() => new B().foo();
150 test4() => new C().foo();
151 test5() => (a ? new A() : new B()).foo();
152 test6() => (a ? new B() : new C()).foo();
153
154 main() {
155 test1();
156 test2();
157 test3();
158 test4();
159 test5();
160 test6();
161 }
162 """;
163
97 main() { 164 main() {
98 Uri uri = new Uri(scheme: 'source'); 165 Uri uri = new Uri(scheme: 'source');
99 166
100 checkReturn(MockCompiler compiler, String name, type) { 167 checkReturn(MockCompiler compiler, String name, type) {
101 var typesInferrer = compiler.typesTask.typesInferrer; 168 var typesInferrer = compiler.typesTask.typesInferrer;
102 var element = findElement(compiler, name); 169 var element = findElement(compiler, name);
103 Expect.equals( 170 Expect.equals(
104 type, 171 type,
105 simplify(typesInferrer.getReturnTypeOfElement(element), compiler), 172 simplify(typesInferrer.getReturnTypeOfElement(element), compiler),
106 name); 173 name);
(...skipping 20 matching lines...) Expand all
127 checkReturn(compiler2, 'test4', compiler2.typesTask.mapType); 194 checkReturn(compiler2, 'test4', compiler2.typesTask.mapType);
128 checkReturn(compiler2, 'test5', compiler2.typesTask.mapType); 195 checkReturn(compiler2, 'test5', compiler2.typesTask.mapType);
129 196
130 checkReturn(compiler2, 'test6', compiler2.typesTask.numType); 197 checkReturn(compiler2, 'test6', compiler2.typesTask.numType);
131 checkReturn(compiler2, 'test7', compiler2.typesTask.uint31Type); 198 checkReturn(compiler2, 'test7', compiler2.typesTask.uint31Type);
132 checkReturn(compiler2, 'test8', compiler2.typesTask.uint31Type); 199 checkReturn(compiler2, 'test8', compiler2.typesTask.uint31Type);
133 checkReturn(compiler2, 'test9', compiler2.typesTask.uint31Type); 200 checkReturn(compiler2, 'test9', compiler2.typesTask.uint31Type);
134 checkReturn(compiler2, 'test10', compiler2.typesTask.numType); 201 checkReturn(compiler2, 'test10', compiler2.typesTask.numType);
135 checkReturn(compiler2, 'test11', compiler2.typesTask.doubleType); 202 checkReturn(compiler2, 'test11', compiler2.typesTask.doubleType);
136 })); 203 }));
204
205 var compiler3 = compilerFor(TEST3, uri);
206 asyncTest(() => compiler3.runCompiler(uri).then((_) {
207 checkReturn(compiler3, 'test1', const TypeMask.nonNullEmpty());
208 checkReturn(compiler3, 'test2', compiler3.typesTask.mapType);
209 checkReturn(compiler3, 'test3', compiler3.typesTask.mapType);
210 checkReturn(compiler3, 'test4', compiler3.typesTask.mapType);
211 checkReturn(compiler3, 'test5', compiler3.typesTask.mapType);
212 checkReturn(compiler3, 'test6', compiler3.typesTask.mapType);
213 }));
214
215 var compiler4 = compilerFor(TEST4, uri);
216 asyncTest(() => compiler4.runCompiler(uri).then((_) {
217 checkReturn(compiler4, 'test1', const TypeMask.nonNullEmpty());
218 checkReturn(compiler4, 'test2', compiler4.typesTask.mapType);
219 checkReturn(compiler4, 'test3', compiler4.typesTask.mapType);
220 checkReturn(compiler4, 'test4', compiler4.typesTask.mapType);
221 checkReturn(compiler4, 'test5', compiler4.typesTask.mapType);
222 checkReturn(compiler4, 'test6', compiler4.typesTask.mapType);
223 }));
137 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698