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

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

Issue 2846433003: Run closed_world2_test using the normal compiler pipeline. (Closed)
Patch Set: Updated cf. comments Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 7
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 class J1 extends K1 {} 110 class J1 extends K1 {}
111 class J2 implements K2 {} 111 class J2 implements K2 {}
112 class K1 {} 112 class K1 {}
113 class K2 {} 113 class K2 {}
114 class L1 {} 114 class L1 {}
115 class A implements I1, I2 {} 115 class A implements I1, I2 {}
116 class B extends A implements J1, J2 {} 116 class B extends A implements J1, J2 {}
117 class C extends B implements L1 {} 117 class C extends B implements L1 {}
118 """); 118 """);
119 compiler.resolveStatement("C c;"); 119 compiler.resolveStatement("C c;");
120 ClassElement classA = compiler.mainApp.find("A"); 120 LibraryElement mainApp = compiler.mainApp;
121 ClassElement classB = compiler.mainApp.find("B"); 121 ClassElement classA = mainApp.find("A");
122 ClassElement classC = compiler.mainApp.find("C"); 122 ClassElement classB = mainApp.find("B");
123 ClassElement classC = mainApp.find("C");
123 Expect.equals('[ I2, I1, Object ]', classA.allSupertypes.toString()); 124 Expect.equals('[ I2, I1, Object ]', classA.allSupertypes.toString());
124 Expect.equals('[ A, J2, J1, I2, I1, K2, K1, Object ]', 125 Expect.equals('[ A, J2, J1, I2, I1, K2, K1, Object ]',
125 classB.allSupertypes.toString()); 126 classB.allSupertypes.toString());
126 Expect.equals('[ B, L1, A, J2, J1, I2, I1, K2, K1, Object ]', 127 Expect.equals('[ B, L1, A, J2, J1, I2, I1, K2, K1, Object ]',
127 classC.allSupertypes.toString()); 128 classC.allSupertypes.toString());
128 }), 129 }),
129 MockCompiler.create((MockCompiler compiler) { 130 MockCompiler.create((MockCompiler compiler) {
130 compiler.parseScript(""" 131 compiler.parseScript("""
131 class X<T> {} 132 class X<T> {}
132 class Foo extends X<Foo> {} 133 class Foo extends X<Foo> {}
133 class Bar extends Foo implements X<Bar> {} 134 class Bar extends Foo implements X<Bar> {}
134 """); 135 """);
135 compiler.resolveStatement("Bar bar;"); 136 compiler.resolveStatement("Bar bar;");
136 ClassElement classBar = compiler.mainApp.find("Bar"); 137 LibraryElement mainApp = compiler.mainApp;
138 ClassElement classBar = mainApp.find("Bar");
137 DiagnosticCollector collector = compiler.diagnosticCollector; 139 DiagnosticCollector collector = compiler.diagnosticCollector;
138 Expect.equals(0, collector.warnings.length); 140 Expect.equals(0, collector.warnings.length);
139 Expect.equals(1, collector.errors.length); 141 Expect.equals(1, collector.errors.length);
140 Expect.equals( 142 Expect.equals(
141 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind); 143 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind);
142 Expect.equals(0, collector.crashes.length); 144 Expect.equals(0, collector.crashes.length);
143 }), 145 }),
144 ]); 146 ]);
145 } 147 }
146 148
(...skipping 12 matching lines...) Expand all
159 Expect.equals(expectedElements[index], argument.element); 161 Expect.equals(expectedElements[index], argument.element);
160 index++; 162 index++;
161 } 163 }
162 Expect.equals(index, expectedElements.length); 164 Expect.equals(index, expectedElements.length);
163 } 165 }
164 166
165 return Future.wait([ 167 return Future.wait([
166 MockCompiler.create((MockCompiler compiler) { 168 MockCompiler.create((MockCompiler compiler) {
167 ResolverVisitor visitor = compiler.resolverVisitor(); 169 ResolverVisitor visitor = compiler.resolverVisitor();
168 compiler.parseScript('class Foo<T, U> {}'); 170 compiler.parseScript('class Foo<T, U> {}');
169 ClassElement foo = compiler.mainApp.find('Foo'); 171 LibraryElement mainApp = compiler.mainApp;
172 ClassElement foo = mainApp.find('Foo');
170 matchResolvedTypes(visitor, 'Foo<int, String> x;', 'Foo', [ 173 matchResolvedTypes(visitor, 'Foo<int, String> x;', 'Foo', [
171 compiler.commonElements.intClass, 174 compiler.commonElements.intClass,
172 compiler.commonElements.stringClass 175 compiler.commonElements.stringClass
173 ]); 176 ]);
174 matchResolvedTypes(visitor, 'Foo<Foo, Foo> x;', 'Foo', [foo, foo]); 177 matchResolvedTypes(visitor, 'Foo<Foo, Foo> x;', 'Foo', [foo, foo]);
175 }), 178 }),
176 MockCompiler.create((MockCompiler compiler) { 179 MockCompiler.create((MockCompiler compiler) {
177 compiler.parseScript('class Foo<T, U> {}'); 180 compiler.parseScript('class Foo<T, U> {}');
178 compiler.resolveStatement('Foo<notype, int> x;'); 181 compiler.resolveStatement('Foo<notype, int> x;');
179 DiagnosticCollector collector = compiler.diagnosticCollector; 182 DiagnosticCollector collector = compiler.diagnosticCollector;
(...skipping 10 matching lines...) Expand all
190 Expect.equals(0, collector.errors.length); 193 Expect.equals(0, collector.errors.length);
191 Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE, 194 Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE,
192 collector.warnings.first.message.kind); 195 collector.warnings.first.message.kind);
193 }), 196 }),
194 MockCompiler.create((MockCompiler compiler) { 197 MockCompiler.create((MockCompiler compiler) {
195 compiler.parseScript('class Foo<T> {' 198 compiler.parseScript('class Foo<T> {'
196 ' Foo<T> t;' 199 ' Foo<T> t;'
197 ' foo(Foo<T> f) {}' 200 ' foo(Foo<T> f) {}'
198 ' bar() { g(Foo<T> f) {}; g(); }' 201 ' bar() { g(Foo<T> f) {}; g(); }'
199 '}'); 202 '}');
200 ClassElement foo = compiler.mainApp.find('Foo'); 203 LibraryElement mainApp = compiler.mainApp;
204 ClassElement foo = mainApp.find('Foo');
201 foo.ensureResolved(compiler.resolution); 205 foo.ensureResolved(compiler.resolution);
202 MemberElement tMember = foo.lookupLocalMember('t'); 206 MemberElement tMember = foo.lookupLocalMember('t');
203 tMember.computeType(compiler.resolution); 207 tMember.computeType(compiler.resolution);
204 MemberElement fooMember = foo.lookupLocalMember('foo'); 208 MemberElement fooMember = foo.lookupLocalMember('foo');
205 fooMember.computeType(compiler.resolution); 209 fooMember.computeType(compiler.resolution);
206 compiler.resolver.resolve(foo.lookupLocalMember('bar')); 210 compiler.resolver.resolve(foo.lookupLocalMember('bar'));
207 DiagnosticCollector collector = compiler.diagnosticCollector; 211 DiagnosticCollector collector = compiler.diagnosticCollector;
208 Expect.equals(0, collector.warnings.length); 212 Expect.equals(0, collector.warnings.length);
209 Expect.equals(0, collector.errors.length); 213 Expect.equals(0, collector.errors.length);
210 }), 214 }),
211 ]); 215 ]);
212 } 216 }
213 217
214 Future testSuperCalls() { 218 Future testSuperCalls() {
215 return MockCompiler.create((MockCompiler compiler) { 219 return MockCompiler.create((MockCompiler compiler) {
216 String script = """class A { foo() {} } 220 String script = """class A { foo() {} }
217 class B extends A { foo() => super.foo(); }"""; 221 class B extends A { foo() => super.foo(); }""";
218 compiler.parseScript(script); 222 compiler.parseScript(script);
219 compiler.resolveStatement("B b;"); 223 compiler.resolveStatement("B b;");
220 224
221 ClassElement classB = compiler.mainApp.find("B"); 225 LibraryElement mainApp = compiler.mainApp;
226 ClassElement classB = mainApp.find("B");
222 FunctionElement fooB = classB.lookupLocalMember("foo"); 227 FunctionElement fooB = classB.lookupLocalMember("foo");
223 ClassElement classA = compiler.mainApp.find("A"); 228 ClassElement classA = mainApp.find("A");
224 FunctionElement fooA = classA.lookupLocalMember("foo"); 229 FunctionElement fooA = classA.lookupLocalMember("foo");
225 230
226 ResolverVisitor visitor = new ResolverVisitor( 231 ResolverVisitor visitor = new ResolverVisitor(
227 compiler.resolution, 232 compiler.resolution,
228 fooB, 233 fooB,
229 new ResolutionRegistry( 234 new ResolutionRegistry(
230 compiler.backend.target, new CollectingTreeElements(fooB)), 235 compiler.backend.target, new CollectingTreeElements(fooB)),
231 scope: new MockTypeVariablesScope(classB.buildScope())); 236 scope: new MockTypeVariablesScope(classB.buildScope()));
232 FunctionExpression node = 237 FunctionExpression node =
233 (fooB as FunctionElementX).parseNode(compiler.parsingContext); 238 (fooB as FunctionElementX).parseNode(compiler.parsingContext);
234 visitor.visit(node.body); 239 visitor.visit(node.body);
235 Map mapping = map(visitor); 240 Map mapping = map(visitor);
236 241
237 Send superCall = node.body.asReturn().expression; 242 Send superCall = node.body.asReturn().expression;
238 FunctionElement called = mapping[superCall]; 243 FunctionElement called = mapping[superCall];
239 Expect.isNotNull(called); 244 Expect.isNotNull(called);
240 Expect.equals(fooA, called); 245 Expect.equals(fooA, called);
241 }); 246 });
242 } 247 }
243 248
244 Future testSwitch() { 249 Future testSwitch() {
245 return MockCompiler.create((MockCompiler compiler) { 250 return MockCompiler.create((MockCompiler compiler) {
246 compiler.parseScript("class Foo { foo() {" 251 compiler.parseScript("class Foo { foo() {"
247 "switch (null) { case '': break; case 2: break; } } }"); 252 "switch (null) { case '': break; case 2: break; } } }");
248 compiler.resolveStatement("Foo foo;"); 253 compiler.resolveStatement("Foo foo;");
249 ClassElement fooElement = compiler.mainApp.find("Foo"); 254 LibraryElement mainApp = compiler.mainApp;
255 ClassElement fooElement = mainApp.find("Foo");
250 MethodElement funElement = fooElement.lookupLocalMember("foo"); 256 MethodElement funElement = fooElement.lookupLocalMember("foo");
251 compiler.enqueuer.resolution.applyImpact(new WorldImpactBuilderImpl() 257 compiler.enqueuer.resolution.applyImpact(new WorldImpactBuilderImpl()
252 ..registerStaticUse(new StaticUse.implicitInvoke(funElement))); 258 ..registerStaticUse(new StaticUse.implicitInvoke(funElement)));
253 compiler.processQueue( 259 compiler.processQueue(
254 compiler.enqueuer.resolution, null, compiler.libraryLoader.libraries); 260 compiler.enqueuer.resolution, null, compiler.libraryLoader.libraries);
255 DiagnosticCollector collector = compiler.diagnosticCollector; 261 DiagnosticCollector collector = compiler.diagnosticCollector;
256 Expect.equals(0, collector.warnings.length); 262 Expect.equals(0, collector.warnings.length);
257 Expect.equals(1, collector.errors.length); 263 Expect.equals(1, collector.errors.length);
258 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL, 264 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL,
259 collector.errors.first.message.kind); 265 collector.errors.first.message.kind);
260 Expect.equals(2, collector.infos.length); 266 Expect.equals(2, collector.infos.length);
261 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, 267 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
262 collector.infos.first.message.kind); 268 collector.infos.first.message.kind);
263 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, 269 Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE,
264 collector.infos.elementAt(1).message.kind); 270 collector.infos.elementAt(1).message.kind);
265 }); 271 });
266 } 272 }
267 273
268 Future testThis() { 274 Future testThis() {
269 return Future.wait([ 275 return Future.wait([
270 MockCompiler.create((MockCompiler compiler) { 276 MockCompiler.create((MockCompiler compiler) {
271 compiler.parseScript("class Foo { foo() { return this; } }"); 277 compiler.parseScript("class Foo { foo() { return this; } }");
272 compiler.resolveStatement("Foo foo;"); 278 compiler.resolveStatement("Foo foo;");
273 ClassElement fooElement = compiler.mainApp.find("Foo"); 279 LibraryElement mainApp = compiler.mainApp;
280 ClassElement fooElement = mainApp.find("Foo");
274 FunctionElement funElement = fooElement.lookupLocalMember("foo"); 281 FunctionElement funElement = fooElement.lookupLocalMember("foo");
275 ResolverVisitor visitor = new ResolverVisitor( 282 ResolverVisitor visitor = new ResolverVisitor(
276 compiler.resolution, 283 compiler.resolution,
277 funElement, 284 funElement,
278 new ResolutionRegistry( 285 new ResolutionRegistry(
279 compiler.backend.target, new CollectingTreeElements(funElement)), 286 compiler.backend.target, new CollectingTreeElements(funElement)),
280 scope: new MockTypeVariablesScope(fooElement.buildScope())); 287 scope: new MockTypeVariablesScope(fooElement.buildScope()));
281 FunctionExpression function = 288 FunctionExpression function =
282 (funElement as FunctionElementX).parseNode(compiler.parsingContext); 289 (funElement as FunctionElementX).parseNode(compiler.parsingContext);
283 visitor.visit(function.body); 290 visitor.visit(function.body);
284 Map mapping = map(visitor); 291 Map mapping = map(visitor);
285 List<Element> values = mapping.values.toList(); 292 List<Element> values = mapping.values.toList();
286 DiagnosticCollector collector = compiler.diagnosticCollector; 293 DiagnosticCollector collector = compiler.diagnosticCollector;
287 Expect.equals(0, mapping.length); 294 Expect.equals(0, mapping.length);
288 Expect.equals(0, collector.warnings.length); 295 Expect.equals(0, collector.warnings.length);
289 }), 296 }),
290 MockCompiler.create((MockCompiler compiler) { 297 MockCompiler.create((MockCompiler compiler) {
291 compiler.resolveStatement("main() { return this; }"); 298 compiler.resolveStatement("main() { return this; }");
292 DiagnosticCollector collector = compiler.diagnosticCollector; 299 DiagnosticCollector collector = compiler.diagnosticCollector;
293 Expect.equals(0, collector.warnings.length); 300 Expect.equals(0, collector.warnings.length);
294 Expect.equals(1, collector.errors.length); 301 Expect.equals(1, collector.errors.length);
295 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, 302 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE,
296 collector.errors.first.message.kind); 303 collector.errors.first.message.kind);
297 }), 304 }),
298 MockCompiler.create((MockCompiler compiler) { 305 MockCompiler.create((MockCompiler compiler) {
299 compiler.parseScript("class Foo { static foo() { return this; } }"); 306 compiler.parseScript("class Foo { static foo() { return this; } }");
300 compiler.resolveStatement("Foo foo;"); 307 compiler.resolveStatement("Foo foo;");
301 ClassElement fooElement = compiler.mainApp.find("Foo"); 308 LibraryElement mainApp = compiler.mainApp;
309 ClassElement fooElement = mainApp.find("Foo");
302 FunctionElement funElement = fooElement.lookupLocalMember("foo"); 310 FunctionElement funElement = fooElement.lookupLocalMember("foo");
303 ResolverVisitor visitor = new ResolverVisitor( 311 ResolverVisitor visitor = new ResolverVisitor(
304 compiler.resolution, 312 compiler.resolution,
305 funElement, 313 funElement,
306 new ResolutionRegistry( 314 new ResolutionRegistry(
307 compiler.backend.target, new CollectingTreeElements(funElement)), 315 compiler.backend.target, new CollectingTreeElements(funElement)),
308 scope: new MockTypeVariablesScope(fooElement.buildScope())); 316 scope: new MockTypeVariablesScope(fooElement.buildScope()));
309 FunctionExpression function = 317 FunctionExpression function =
310 (funElement as FunctionElementX).parseNode(compiler.parsingContext); 318 (funElement as FunctionElementX).parseNode(compiler.parsingContext);
311 visitor.visit(function.body); 319 visitor.visit(function.body);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 false); 580 false);
573 Expect.equals(cannotResolveBar, collector.errors.first.message); 581 Expect.equals(cannotResolveBar, collector.errors.first.message);
574 collector.clear(); 582 collector.clear();
575 }), 583 }),
576 MockCompiler.create((MockCompiler compiler) { 584 MockCompiler.create((MockCompiler compiler) {
577 compiler.parseScript("class Foo extends Bar {}"); 585 compiler.parseScript("class Foo extends Bar {}");
578 compiler.parseScript("class Bar {}"); 586 compiler.parseScript("class Bar {}");
579 Map mapping = compiler.resolveStatement("Foo bar;").map; 587 Map mapping = compiler.resolveStatement("Foo bar;").map;
580 Expect.equals(1, mapping.length); 588 Expect.equals(1, mapping.length);
581 589
582 ClassElement fooElement = compiler.mainApp.find('Foo'); 590 LibraryElement mainApp = compiler.mainApp;
583 ClassElement barElement = compiler.mainApp.find('Bar'); 591 ClassElement fooElement = mainApp.find('Foo');
592 ClassElement barElement = mainApp.find('Bar');
584 Expect.equals( 593 Expect.equals(
585 barElement.computeType(compiler.resolution), fooElement.supertype); 594 barElement.computeType(compiler.resolution), fooElement.supertype);
586 Expect.isTrue(fooElement.interfaces.isEmpty); 595 Expect.isTrue(fooElement.interfaces.isEmpty);
587 Expect.isTrue(barElement.interfaces.isEmpty); 596 Expect.isTrue(barElement.interfaces.isEmpty);
588 }), 597 }),
589 ]); 598 ]);
590 } 599 }
591 600
592 Future testVarSuperclass() { 601 Future testVarSuperclass() {
593 return MockCompiler.create((MockCompiler compiler) { 602 return MockCompiler.create((MockCompiler compiler) {
(...skipping 25 matching lines...) Expand all
619 // correctly. 628 // correctly.
620 compiler.parseScript("abstract class Bar {}"); 629 compiler.parseScript("abstract class Bar {}");
621 630
622 ResolverVisitor visitor = new ResolverVisitor( 631 ResolverVisitor visitor = new ResolverVisitor(
623 compiler.resolution, 632 compiler.resolution,
624 null, 633 null,
625 new ResolutionRegistry( 634 new ResolutionRegistry(
626 compiler.backend.target, new CollectingTreeElements(null))); 635 compiler.backend.target, new CollectingTreeElements(null)));
627 compiler.resolveStatement("Foo bar;"); 636 compiler.resolveStatement("Foo bar;");
628 637
629 ClassElement fooElement = compiler.mainApp.find('Foo'); 638 LibraryElement mainApp = compiler.mainApp;
630 ClassElement barElement = compiler.mainApp.find('Bar'); 639 ClassElement fooElement = mainApp.find('Foo');
640 ClassElement barElement = mainApp.find('Bar');
631 641
632 Expect.equals(null, barElement.supertype); 642 Expect.equals(null, barElement.supertype);
633 Expect.isTrue(barElement.interfaces.isEmpty); 643 Expect.isTrue(barElement.interfaces.isEmpty);
634 644
635 Expect.equals(barElement.computeType(compiler.resolution), 645 Expect.equals(barElement.computeType(compiler.resolution),
636 fooElement.interfaces.head); 646 fooElement.interfaces.head);
637 Expect.equals(1, length(fooElement.interfaces)); 647 Expect.equals(1, length(fooElement.interfaces));
638 }); 648 });
639 } 649 }
640 650
641 Future testTwoInterfaces() { 651 Future testTwoInterfaces() {
642 return MockCompiler.create((MockCompiler compiler) { 652 return MockCompiler.create((MockCompiler compiler) {
643 compiler.parseScript("""abstract class I1 {} 653 compiler.parseScript("""abstract class I1 {}
644 abstract class I2 {} 654 abstract class I2 {}
645 class C implements I1, I2 {}"""); 655 class C implements I1, I2 {}""");
646 compiler.resolveStatement("Foo bar;"); 656 compiler.resolveStatement("Foo bar;");
647 657
648 ClassElement c = compiler.mainApp.find('C'); 658 LibraryElement mainApp = compiler.mainApp;
649 ClassElement i1 = compiler.mainApp.find('I1'); 659 ClassElement c = mainApp.find('C');
650 ClassElement i2 = compiler.mainApp.find('I2'); 660 ClassElement i1 = mainApp.find('I1');
661 ClassElement i2 = mainApp.find('I2');
651 662
652 Expect.equals(2, length(c.interfaces)); 663 Expect.equals(2, length(c.interfaces));
653 Expect.equals(i1.computeType(compiler.resolution), at(c.interfaces, 0)); 664 Expect.equals(i1.computeType(compiler.resolution), at(c.interfaces, 0));
654 Expect.equals(i2.computeType(compiler.resolution), at(c.interfaces, 1)); 665 Expect.equals(i2.computeType(compiler.resolution), at(c.interfaces, 1));
655 }); 666 });
656 } 667 }
657 668
658 Future testFunctionExpression() { 669 Future testFunctionExpression() {
659 return MockCompiler.create((MockCompiler compiler) { 670 return MockCompiler.create((MockCompiler compiler) {
660 Map mapping = compiler.resolveStatement("int f() {}").map; 671 Map mapping = compiler.resolveStatement("int f() {}").map;
661 Expect.equals(2, mapping.length); 672 Expect.equals(2, mapping.length);
662 Element element; 673 Element element;
663 Node node; 674 Node node;
664 mapping.forEach((Node n, Element e) { 675 mapping.forEach((Node n, Element e) {
665 if (n is FunctionExpression) { 676 if (n is FunctionExpression) {
666 element = e; 677 element = e;
667 node = n; 678 node = n;
668 } 679 }
669 }); 680 });
670 Expect.equals(ElementKind.FUNCTION, element.kind); 681 Expect.equals(ElementKind.FUNCTION, element.kind);
671 Expect.equals('f', element.name); 682 Expect.equals('f', element.name);
672 Expect.equals((element as FunctionElement).node, node); 683 Expect.equals((element as FunctionElement).node, node);
673 }); 684 });
674 } 685 }
675 686
676 Future testNewExpression() { 687 Future testNewExpression() {
677 return MockCompiler.create((MockCompiler compiler) { 688 return MockCompiler.create((MockCompiler compiler) {
678 compiler.parseScript("class A {} foo() { print(new A()); }"); 689 compiler.parseScript("class A {} foo() { print(new A()); }");
679 ClassElement aElement = compiler.mainApp.find('A'); 690 LibraryElement mainApp = compiler.mainApp;
691 ClassElement aElement = mainApp.find('A');
680 692
681 FunctionElement fooElement = compiler.mainApp.find('foo'); 693 FunctionElement fooElement = mainApp.find('foo');
682 compiler.resolver.resolve(fooElement); 694 compiler.resolver.resolve(fooElement);
683 695
684 Expect.isNotNull(aElement); 696 Expect.isNotNull(aElement);
685 Expect.isNotNull(fooElement); 697 Expect.isNotNull(fooElement);
686 698
687 fooElement.node; 699 fooElement.node;
688 compiler.resolver.resolve(fooElement); 700 compiler.resolver.resolve(fooElement);
689 701
690 TreeElements elements = compiler.resolveStatement("new A();"); 702 TreeElements elements = compiler.resolveStatement("new A();");
691 NewExpression expression = 703 NewExpression expression =
692 compiler.parsedTree.asExpressionStatement().expression; 704 compiler.parsedTree.asExpressionStatement().expression;
693 Element element = elements[expression.send]; 705 Element element = elements[expression.send];
694 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); 706 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind);
695 Expect.isTrue(element.isSynthesized); 707 Expect.isTrue(element.isSynthesized);
696 }); 708 });
697 } 709 }
698 710
699 Future testTopLevelFields() { 711 Future testTopLevelFields() {
700 return MockCompiler.create((MockCompiler compiler) { 712 return MockCompiler.create((MockCompiler compiler) {
701 compiler.parseScript("int a;"); 713 compiler.parseScript("int a;");
702 VariableElementX element = compiler.mainApp.find("a"); 714 LibraryElement mainApp = compiler.mainApp;
715 VariableElementX element = mainApp.find("a");
703 Expect.equals(ElementKind.FIELD, element.kind); 716 Expect.equals(ElementKind.FIELD, element.kind);
704 VariableDefinitions node = 717 VariableDefinitions node =
705 element.variables.parseNode(element, compiler.parsingContext); 718 element.variables.parseNode(element, compiler.parsingContext);
706 NominalTypeAnnotation annotation = node.type; 719 NominalTypeAnnotation annotation = node.type;
707 Identifier typeName = annotation.typeName; 720 Identifier typeName = annotation.typeName;
708 Expect.equals(typeName.source, 'int'); 721 Expect.equals(typeName.source, 'int');
709 722
710 compiler.parseScript("var b, c;"); 723 compiler.parseScript("var b, c;");
711 VariableElementX bElement = compiler.mainApp.find("b"); 724 VariableElementX bElement = mainApp.find("b");
712 VariableElementX cElement = compiler.mainApp.find("c"); 725 VariableElementX cElement = mainApp.find("c");
713 Expect.equals(ElementKind.FIELD, bElement.kind); 726 Expect.equals(ElementKind.FIELD, bElement.kind);
714 Expect.equals(ElementKind.FIELD, cElement.kind); 727 Expect.equals(ElementKind.FIELD, cElement.kind);
715 Expect.isTrue(bElement != cElement); 728 Expect.isTrue(bElement != cElement);
716 729
717 VariableDefinitions bNode = 730 VariableDefinitions bNode =
718 bElement.variables.parseNode(bElement, compiler.parsingContext); 731 bElement.variables.parseNode(bElement, compiler.parsingContext);
719 VariableDefinitions cNode = 732 VariableDefinitions cNode =
720 cElement.variables.parseNode(cElement, compiler.parsingContext); 733 cElement.variables.parseNode(cElement, compiler.parsingContext);
721 Expect.equals(bNode, cNode); 734 Expect.equals(bNode, cNode);
722 Expect.isNull(bNode.type); 735 Expect.isNull(bNode.type);
723 Expect.isTrue(bNode.modifiers.isVar); 736 Expect.isTrue(bNode.modifiers.isVar);
724 }); 737 });
725 } 738 }
726 739
727 Future resolveConstructor(String script, String statement, String className, 740 Future resolveConstructor(String script, String statement, String className,
728 String constructor, int expectedElementCount, 741 String constructor, int expectedElementCount,
729 {List expectedWarnings: const [], 742 {List expectedWarnings: const [],
730 List expectedErrors: const [], 743 List expectedErrors: const [],
731 List expectedInfos: const [], 744 List expectedInfos: const [],
732 Map<String, String> corelib}) { 745 Map<String, String> corelib}) {
733 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib); 746 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib);
734 return compiler.init().then((_) { 747 return compiler.init().then((_) {
735 compiler.parseScript(script); 748 compiler.parseScript(script);
736 compiler.resolveStatement(statement); 749 compiler.resolveStatement(statement);
737 ClassElement classElement = compiler.mainApp.find(className); 750 LibraryElement mainApp = compiler.mainApp;
751 ClassElement classElement = mainApp.find(className);
738 Element element; 752 Element element;
739 element = classElement.lookupConstructor(constructor); 753 element = classElement.lookupConstructor(constructor);
740 FunctionExpression tree = (element as FunctionElement).node; 754 FunctionExpression tree = (element as FunctionElement).node;
741 ResolverVisitor visitor = new ResolverVisitor( 755 ResolverVisitor visitor = new ResolverVisitor(
742 compiler.resolution, 756 compiler.resolution,
743 element, 757 element,
744 new ResolutionRegistry( 758 new ResolutionRegistry(
745 compiler.backend.target, new CollectingTreeElements(element)), 759 compiler.backend.target, new CollectingTreeElements(element)),
746 scope: classElement.buildScope()); 760 scope: classElement.buildScope());
747 new InitializerResolver(visitor, element, tree).resolveInitializers(); 761 new InitializerResolver(visitor, element, tree).resolveInitializers();
748 visitor.visit(tree.body); 762 visitor.visit(tree.body);
749 Expect.equals(expectedElementCount, map(visitor).length, 763 Expect.equals(expectedElementCount, map(visitor).length,
750 "${map(visitor).values} for '$statement' in context of `$script`"); 764 "${map(visitor).values} for '$statement' in context of `$script`");
751 765
752 DiagnosticCollector collector = compiler.diagnosticCollector; 766 DiagnosticCollector collector = compiler.diagnosticCollector;
753 compareWarningKinds(script, expectedWarnings, collector.warnings); 767 compareWarningKinds(script, expectedWarnings, collector.warnings);
754 compareWarningKinds(script, expectedErrors, collector.errors); 768 compareWarningKinds(script, expectedErrors, collector.errors);
755 compareWarningKinds(script, expectedInfos, collector.infos); 769 compareWarningKinds(script, expectedInfos, collector.infos);
756 }); 770 });
757 } 771 }
758 772
759 Future testClassHierarchy() { 773 Future testClassHierarchy() {
760 final MAIN = "main"; 774 final MAIN = "main";
761 return Future.wait([ 775 return Future.wait([
762 MockCompiler.create((MockCompiler compiler) { 776 MockCompiler.create((MockCompiler compiler) {
763 compiler.parseScript("""class A extends A {} 777 compiler.parseScript("""class A extends A {}
764 main() { return new A(); }"""); 778 main() { return new A(); }""");
765 FunctionElement mainElement = compiler.mainApp.find(MAIN); 779 LibraryElement mainApp = compiler.mainApp;
780 FunctionElement mainElement = mainApp.find(MAIN);
766 compiler.resolver.resolve(mainElement); 781 compiler.resolver.resolve(mainElement);
767 DiagnosticCollector collector = compiler.diagnosticCollector; 782 DiagnosticCollector collector = compiler.diagnosticCollector;
768 Expect.equals(0, collector.warnings.length); 783 Expect.equals(0, collector.warnings.length);
769 Expect.equals(1, collector.errors.length); 784 Expect.equals(1, collector.errors.length);
770 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, 785 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
771 collector.errors.first.message.kind); 786 collector.errors.first.message.kind);
772 }), 787 }),
773 MockCompiler.create((MockCompiler compiler) { 788 MockCompiler.create((MockCompiler compiler) {
774 compiler.parseScript("""class A extends B {} 789 compiler.parseScript("""class A extends B {}
775 class B extends A {} 790 class B extends A {}
776 main() { return new A(); }"""); 791 main() { return new A(); }""");
777 FunctionElement mainElement = compiler.mainApp.find(MAIN); 792 LibraryElement mainApp = compiler.mainApp;
793 FunctionElement mainElement = mainApp.find(MAIN);
778 compiler.resolver.resolve(mainElement); 794 compiler.resolver.resolve(mainElement);
779 DiagnosticCollector collector = compiler.diagnosticCollector; 795 DiagnosticCollector collector = compiler.diagnosticCollector;
780 Expect.equals(0, collector.warnings.length); 796 Expect.equals(0, collector.warnings.length);
781 Expect.equals(2, collector.errors.length); 797 Expect.equals(2, collector.errors.length);
782 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, 798 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
783 collector.errors.first.message.kind); 799 collector.errors.first.message.kind);
784 Expect.equals(MessageKind.CANNOT_FIND_UNNAMED_CONSTRUCTOR, 800 Expect.equals(MessageKind.CANNOT_FIND_UNNAMED_CONSTRUCTOR,
785 collector.errors.elementAt(1).message.kind); 801 collector.errors.elementAt(1).message.kind);
786 }), 802 }),
787 MockCompiler.create((MockCompiler compiler) { 803 MockCompiler.create((MockCompiler compiler) {
788 compiler.parseScript("""abstract class A extends B {} 804 compiler.parseScript("""abstract class A extends B {}
789 abstract class B extends A {} 805 abstract class B extends A {}
790 class C implements A {} 806 class C implements A {}
791 main() { return new C(); }"""); 807 main() { return new C(); }""");
792 FunctionElement mainElement = compiler.mainApp.find(MAIN); 808 LibraryElement mainApp = compiler.mainApp;
809 FunctionElement mainElement = mainApp.find(MAIN);
793 compiler.resolver.resolve(mainElement); 810 compiler.resolver.resolve(mainElement);
794 DiagnosticCollector collector = compiler.diagnosticCollector; 811 DiagnosticCollector collector = compiler.diagnosticCollector;
795 Expect.equals(0, collector.warnings.length); 812 Expect.equals(0, collector.warnings.length);
796 Expect.equals(1, collector.errors.length); 813 Expect.equals(1, collector.errors.length);
797 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, 814 Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY,
798 collector.errors.first.message.kind); 815 collector.errors.first.message.kind);
799 }), 816 }),
800 MockCompiler.create((MockCompiler compiler) { 817 MockCompiler.create((MockCompiler compiler) {
801 compiler.parseScript("""class A extends B {} 818 compiler.parseScript("""class A extends B {}
802 class B extends C {} 819 class B extends C {}
803 class C {} 820 class C {}
804 main() { return new A(); }"""); 821 main() { return new A(); }""");
805 FunctionElement mainElement = compiler.mainApp.find(MAIN); 822 LibraryElement mainApp = compiler.mainApp;
823 FunctionElement mainElement = mainApp.find(MAIN);
806 compiler.resolver.resolve(mainElement); 824 compiler.resolver.resolve(mainElement);
807 DiagnosticCollector collector = compiler.diagnosticCollector; 825 DiagnosticCollector collector = compiler.diagnosticCollector;
808 Expect.equals(0, collector.warnings.length); 826 Expect.equals(0, collector.warnings.length);
809 Expect.equals(0, collector.errors.length); 827 Expect.equals(0, collector.errors.length);
810 ClassElement aElement = compiler.mainApp.find("A"); 828 ClassElement aElement = mainApp.find("A");
811 Link<InterfaceType> supertypes = aElement.allSupertypes; 829 Link<InterfaceType> supertypes = aElement.allSupertypes;
812 Expect.equals(<String>['B', 'C', 'Object'].toString(), 830 Expect.equals(<String>['B', 'C', 'Object'].toString(),
813 asSortedStrings(supertypes).toString()); 831 asSortedStrings(supertypes).toString());
814 }), 832 }),
815 MockCompiler.create((MockCompiler compiler) { 833 MockCompiler.create((MockCompiler compiler) {
816 compiler.parseScript("""class A<T> {} 834 compiler.parseScript("""class A<T> {}
817 class B<Z,W> extends A<int> 835 class B<Z,W> extends A<int>
818 implements I<Z,List<W>> {} 836 implements I<Z,List<W>> {}
819 class I<X,Y> {} 837 class I<X,Y> {}
820 class C extends B<bool,String> {} 838 class C extends B<bool,String> {}
821 main() { return new C(); }"""); 839 main() { return new C(); }""");
822 FunctionElement mainElement = compiler.mainApp.find(MAIN); 840 LibraryElement mainApp = compiler.mainApp;
841 FunctionElement mainElement = mainApp.find(MAIN);
823 compiler.resolver.resolve(mainElement); 842 compiler.resolver.resolve(mainElement);
824 DiagnosticCollector collector = compiler.diagnosticCollector; 843 DiagnosticCollector collector = compiler.diagnosticCollector;
825 Expect.equals(0, collector.warnings.length); 844 Expect.equals(0, collector.warnings.length);
826 Expect.equals(0, collector.errors.length); 845 Expect.equals(0, collector.errors.length);
827 ClassElement aElement = compiler.mainApp.find("C"); 846 ClassElement aElement = mainApp.find("C");
828 Link<InterfaceType> supertypes = aElement.allSupertypes; 847 Link<InterfaceType> supertypes = aElement.allSupertypes;
829 // Object is once per inheritance path, that is from both A and I. 848 // Object is once per inheritance path, that is from both A and I.
830 Expect.equals( 849 Expect.equals(
831 <String>[ 850 <String>[
832 'A<int>', 851 'A<int>',
833 'B<bool, String>', 852 'B<bool, String>',
834 'I<bool, List<String>>', 853 'I<bool, List<String>>',
835 'Object' 854 'Object'
836 ].toString(), 855 ].toString(),
837 asSortedStrings(supertypes).toString()); 856 asSortedStrings(supertypes).toString());
838 }), 857 }),
839 MockCompiler.create((MockCompiler compiler) { 858 MockCompiler.create((MockCompiler compiler) {
840 compiler.parseScript("""class A<T> {} 859 compiler.parseScript("""class A<T> {}
841 class D extends A<E> {} 860 class D extends A<E> {}
842 class E extends D {} 861 class E extends D {}
843 main() { return new E(); }"""); 862 main() { return new E(); }""");
844 FunctionElement mainElement = compiler.mainApp.find(MAIN); 863 LibraryElement mainApp = compiler.mainApp;
864 FunctionElement mainElement = mainApp.find(MAIN);
845 compiler.resolver.resolve(mainElement); 865 compiler.resolver.resolve(mainElement);
846 DiagnosticCollector collector = compiler.diagnosticCollector; 866 DiagnosticCollector collector = compiler.diagnosticCollector;
847 Expect.equals(0, collector.warnings.length); 867 Expect.equals(0, collector.warnings.length);
848 Expect.equals(0, collector.errors.length); 868 Expect.equals(0, collector.errors.length);
849 ClassElement aElement = compiler.mainApp.find("E"); 869 ClassElement aElement = mainApp.find("E");
850 Link<InterfaceType> supertypes = aElement.allSupertypes; 870 Link<InterfaceType> supertypes = aElement.allSupertypes;
851 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), 871 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(),
852 asSortedStrings(supertypes).toString()); 872 asSortedStrings(supertypes).toString());
853 }), 873 }),
854 MockCompiler.create((MockCompiler compiler) { 874 MockCompiler.create((MockCompiler compiler) {
855 compiler.parseScript("""class A<T> {} 875 compiler.parseScript("""class A<T> {}
856 class D extends A<int> implements A<double> {} 876 class D extends A<int> implements A<double> {}
857 main() { return new D(); }"""); 877 main() { return new D(); }""");
858 FunctionElement mainElement = compiler.mainApp.find(MAIN); 878 LibraryElement mainApp = compiler.mainApp;
879 FunctionElement mainElement = mainApp.find(MAIN);
859 compiler.resolver.resolve(mainElement); 880 compiler.resolver.resolve(mainElement);
860 DiagnosticCollector collector = compiler.diagnosticCollector; 881 DiagnosticCollector collector = compiler.diagnosticCollector;
861 Expect.equals(0, collector.warnings.length); 882 Expect.equals(0, collector.warnings.length);
862 Expect.equals(1, collector.errors.length); 883 Expect.equals(1, collector.errors.length);
863 Expect.equals( 884 Expect.equals(
864 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind); 885 MessageKind.MULTI_INHERITANCE, collector.errors.first.message.kind);
865 Expect.equals(0, collector.crashes.length); 886 Expect.equals(0, collector.crashes.length);
866 }), 887 }),
867 ]); 888 ]);
868 } 889 }
869 890
870 Future testEnumDeclaration() { 891 Future testEnumDeclaration() {
871 final MAIN = "main"; 892 final MAIN = "main";
872 return Future.wait([ 893 return Future.wait([
873 MockCompiler.create((MockCompiler compiler) { 894 MockCompiler.create((MockCompiler compiler) {
874 compiler.parseScript("""enum Enum {} 895 compiler.parseScript("""enum Enum {}
875 main() { Enum e; }"""); 896 main() { Enum e; }""");
876 FunctionElement mainElement = compiler.mainApp.find(MAIN); 897 LibraryElement mainApp = compiler.mainApp;
898 FunctionElement mainElement = mainApp.find(MAIN);
877 compiler.resolver.resolve(mainElement); 899 compiler.resolver.resolve(mainElement);
878 DiagnosticCollector collector = compiler.diagnosticCollector; 900 DiagnosticCollector collector = compiler.diagnosticCollector;
879 Expect.equals(0, collector.warnings.length, 901 Expect.equals(0, collector.warnings.length,
880 'Unexpected warnings: ${collector.warnings}'); 902 'Unexpected warnings: ${collector.warnings}');
881 Expect.equals( 903 Expect.equals(
882 1, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 904 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
883 }), 905 }),
884 MockCompiler.create((MockCompiler compiler) { 906 MockCompiler.create((MockCompiler compiler) {
885 compiler.parseScript("""enum Enum { A } 907 compiler.parseScript("""enum Enum { A }
886 main() { Enum e = Enum.A; }"""); 908 main() { Enum e = Enum.A; }""");
887 FunctionElement mainElement = compiler.mainApp.find(MAIN); 909 LibraryElement mainApp = compiler.mainApp;
910 FunctionElement mainElement = mainApp.find(MAIN);
888 compiler.resolver.resolve(mainElement); 911 compiler.resolver.resolve(mainElement);
889 DiagnosticCollector collector = compiler.diagnosticCollector; 912 DiagnosticCollector collector = compiler.diagnosticCollector;
890 Expect.equals(0, collector.warnings.length, 913 Expect.equals(0, collector.warnings.length,
891 'Unexpected warnings: ${collector.warnings}'); 914 'Unexpected warnings: ${collector.warnings}');
892 Expect.equals( 915 Expect.equals(
893 0, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 916 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
894 }), 917 }),
895 MockCompiler.create((MockCompiler compiler) { 918 MockCompiler.create((MockCompiler compiler) {
896 compiler.parseScript("""enum Enum { A } 919 compiler.parseScript("""enum Enum { A }
897 main() { Enum e = Enum.B; }"""); 920 main() { Enum e = Enum.B; }""");
898 FunctionElement mainElement = compiler.mainApp.find(MAIN); 921 LibraryElement mainApp = compiler.mainApp;
922 FunctionElement mainElement = mainApp.find(MAIN);
899 compiler.resolver.resolve(mainElement); 923 compiler.resolver.resolve(mainElement);
900 DiagnosticCollector collector = compiler.diagnosticCollector; 924 DiagnosticCollector collector = compiler.diagnosticCollector;
901 Expect.equals(1, collector.warnings.length, 925 Expect.equals(1, collector.warnings.length,
902 'Unexpected warnings: ${collector.warnings}'); 926 'Unexpected warnings: ${collector.warnings}');
903 Expect.equals( 927 Expect.equals(
904 MessageKind.UNDEFINED_GETTER, collector.warnings.first.message.kind); 928 MessageKind.UNDEFINED_GETTER, collector.warnings.first.message.kind);
905 Expect.equals( 929 Expect.equals(
906 0, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 930 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
907 }), 931 }),
908 MockCompiler.create((MockCompiler compiler) { 932 MockCompiler.create((MockCompiler compiler) {
909 compiler.parseScript("""enum Enum { A } 933 compiler.parseScript("""enum Enum { A }
910 main() { List values = Enum.values; }"""); 934 main() { List values = Enum.values; }""");
911 FunctionElement mainElement = compiler.mainApp.find(MAIN); 935 LibraryElement mainApp = compiler.mainApp;
936 FunctionElement mainElement = mainApp.find(MAIN);
912 compiler.resolver.resolve(mainElement); 937 compiler.resolver.resolve(mainElement);
913 DiagnosticCollector collector = compiler.diagnosticCollector; 938 DiagnosticCollector collector = compiler.diagnosticCollector;
914 Expect.equals(0, collector.warnings.length, 939 Expect.equals(0, collector.warnings.length,
915 'Unexpected warnings: ${collector.warnings}'); 940 'Unexpected warnings: ${collector.warnings}');
916 Expect.equals( 941 Expect.equals(
917 0, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 942 0, collector.errors.length, 'Unexpected errors: ${collector.errors}');
918 }), 943 }),
919 MockCompiler.create((MockCompiler compiler) { 944 MockCompiler.create((MockCompiler compiler) {
920 compiler.parseScript("""enum Enum { A } 945 compiler.parseScript("""enum Enum { A }
921 main() { new Enum(0, ''); }"""); 946 main() { new Enum(0, ''); }""");
922 FunctionElement mainElement = compiler.mainApp.find(MAIN); 947 LibraryElement mainApp = compiler.mainApp;
948 FunctionElement mainElement = mainApp.find(MAIN);
923 compiler.resolver.resolve(mainElement); 949 compiler.resolver.resolve(mainElement);
924 DiagnosticCollector collector = compiler.diagnosticCollector; 950 DiagnosticCollector collector = compiler.diagnosticCollector;
925 Expect.equals(0, collector.warnings.length, 951 Expect.equals(0, collector.warnings.length,
926 'Unexpected warnings: ${collector.warnings}'); 952 'Unexpected warnings: ${collector.warnings}');
927 Expect.equals( 953 Expect.equals(
928 1, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 954 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
929 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, 955 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
930 collector.errors.first.message.kind); 956 collector.errors.first.message.kind);
931 }), 957 }),
932 MockCompiler.create((MockCompiler compiler) { 958 MockCompiler.create((MockCompiler compiler) {
933 compiler.parseScript("""enum Enum { A } 959 compiler.parseScript("""enum Enum { A }
934 main() { const Enum(0, ''); }"""); 960 main() { const Enum(0, ''); }""");
935 FunctionElement mainElement = compiler.mainApp.find(MAIN); 961 LibraryElement mainApp = compiler.mainApp;
962 FunctionElement mainElement = mainApp.find(MAIN);
936 compiler.resolver.resolve(mainElement); 963 compiler.resolver.resolve(mainElement);
937 DiagnosticCollector collector = compiler.diagnosticCollector; 964 DiagnosticCollector collector = compiler.diagnosticCollector;
938 Expect.equals(0, collector.warnings.length, 965 Expect.equals(0, collector.warnings.length,
939 'Unexpected warnings: ${collector.warnings}'); 966 'Unexpected warnings: ${collector.warnings}');
940 Expect.equals( 967 Expect.equals(
941 1, collector.errors.length, 'Unexpected errors: ${collector.errors}'); 968 1, collector.errors.length, 'Unexpected errors: ${collector.errors}');
942 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, 969 Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM,
943 collector.errors.first.message.kind); 970 collector.errors.first.message.kind);
944 }), 971 }),
945 ]); 972 ]);
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 functionName: 'm'); 1568 functionName: 'm');
1542 check( 1569 check(
1543 ''' 1570 '''
1544 class A { 1571 class A {
1545 m() => () => await - 3; 1572 m() => () => await - 3;
1546 } 1573 }
1547 main() => new A().m(); 1574 main() => new A().m();
1548 ''', 1575 ''',
1549 className: 'A'); 1576 className: 'A');
1550 } 1577 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/related_types_test.dart ('k') | tests/compiler/dart2js/source_map_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698