| OLD | NEW |
| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 ClassElement classB = compiler.mainApp.find("B"); | 219 ClassElement classB = compiler.mainApp.find("B"); |
| 220 FunctionElement fooB = classB.lookupLocalMember("foo"); | 220 FunctionElement fooB = classB.lookupLocalMember("foo"); |
| 221 ClassElement classA = compiler.mainApp.find("A"); | 221 ClassElement classA = compiler.mainApp.find("A"); |
| 222 FunctionElement fooA = classA.lookupLocalMember("foo"); | 222 FunctionElement fooA = classA.lookupLocalMember("foo"); |
| 223 | 223 |
| 224 ResolverVisitor visitor = new ResolverVisitor( | 224 ResolverVisitor visitor = new ResolverVisitor( |
| 225 compiler.resolution, | 225 compiler.resolution, |
| 226 fooB, | 226 fooB, |
| 227 new ResolutionRegistry( | 227 new ResolutionRegistry( |
| 228 compiler.backend, new CollectingTreeElements(fooB)), | 228 compiler.backend.target, new CollectingTreeElements(fooB)), |
| 229 scope: new MockTypeVariablesScope(classB.buildScope())); | 229 scope: new MockTypeVariablesScope(classB.buildScope())); |
| 230 FunctionExpression node = | 230 FunctionExpression node = |
| 231 (fooB as FunctionElementX).parseNode(compiler.parsingContext); | 231 (fooB as FunctionElementX).parseNode(compiler.parsingContext); |
| 232 visitor.visit(node.body); | 232 visitor.visit(node.body); |
| 233 Map mapping = map(visitor); | 233 Map mapping = map(visitor); |
| 234 | 234 |
| 235 Send superCall = node.body.asReturn().expression; | 235 Send superCall = node.body.asReturn().expression; |
| 236 FunctionElement called = mapping[superCall]; | 236 FunctionElement called = mapping[superCall]; |
| 237 Expect.isNotNull(called); | 237 Expect.isNotNull(called); |
| 238 Expect.equals(fooA, called); | 238 Expect.equals(fooA, called); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 267 return Future.wait([ | 267 return Future.wait([ |
| 268 MockCompiler.create((MockCompiler compiler) { | 268 MockCompiler.create((MockCompiler compiler) { |
| 269 compiler.parseScript("class Foo { foo() { return this; } }"); | 269 compiler.parseScript("class Foo { foo() { return this; } }"); |
| 270 compiler.resolveStatement("Foo foo;"); | 270 compiler.resolveStatement("Foo foo;"); |
| 271 ClassElement fooElement = compiler.mainApp.find("Foo"); | 271 ClassElement fooElement = compiler.mainApp.find("Foo"); |
| 272 FunctionElement funElement = fooElement.lookupLocalMember("foo"); | 272 FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| 273 ResolverVisitor visitor = new ResolverVisitor( | 273 ResolverVisitor visitor = new ResolverVisitor( |
| 274 compiler.resolution, | 274 compiler.resolution, |
| 275 funElement, | 275 funElement, |
| 276 new ResolutionRegistry( | 276 new ResolutionRegistry( |
| 277 compiler.backend, new CollectingTreeElements(funElement)), | 277 compiler.backend.target, new CollectingTreeElements(funElement)), |
| 278 scope: new MockTypeVariablesScope(fooElement.buildScope())); | 278 scope: new MockTypeVariablesScope(fooElement.buildScope())); |
| 279 FunctionExpression function = | 279 FunctionExpression function = |
| 280 (funElement as FunctionElementX).parseNode(compiler.parsingContext); | 280 (funElement as FunctionElementX).parseNode(compiler.parsingContext); |
| 281 visitor.visit(function.body); | 281 visitor.visit(function.body); |
| 282 Map mapping = map(visitor); | 282 Map mapping = map(visitor); |
| 283 List<Element> values = mapping.values.toList(); | 283 List<Element> values = mapping.values.toList(); |
| 284 DiagnosticCollector collector = compiler.diagnosticCollector; | 284 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 285 Expect.equals(0, mapping.length); | 285 Expect.equals(0, mapping.length); |
| 286 Expect.equals(0, collector.warnings.length); | 286 Expect.equals(0, collector.warnings.length); |
| 287 }), | 287 }), |
| 288 MockCompiler.create((MockCompiler compiler) { | 288 MockCompiler.create((MockCompiler compiler) { |
| 289 compiler.resolveStatement("main() { return this; }"); | 289 compiler.resolveStatement("main() { return this; }"); |
| 290 DiagnosticCollector collector = compiler.diagnosticCollector; | 290 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 291 Expect.equals(0, collector.warnings.length); | 291 Expect.equals(0, collector.warnings.length); |
| 292 Expect.equals(1, collector.errors.length); | 292 Expect.equals(1, collector.errors.length); |
| 293 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, | 293 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| 294 collector.errors.first.message.kind); | 294 collector.errors.first.message.kind); |
| 295 }), | 295 }), |
| 296 MockCompiler.create((MockCompiler compiler) { | 296 MockCompiler.create((MockCompiler compiler) { |
| 297 compiler.parseScript("class Foo { static foo() { return this; } }"); | 297 compiler.parseScript("class Foo { static foo() { return this; } }"); |
| 298 compiler.resolveStatement("Foo foo;"); | 298 compiler.resolveStatement("Foo foo;"); |
| 299 ClassElement fooElement = compiler.mainApp.find("Foo"); | 299 ClassElement fooElement = compiler.mainApp.find("Foo"); |
| 300 FunctionElement funElement = fooElement.lookupLocalMember("foo"); | 300 FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| 301 ResolverVisitor visitor = new ResolverVisitor( | 301 ResolverVisitor visitor = new ResolverVisitor( |
| 302 compiler.resolution, | 302 compiler.resolution, |
| 303 funElement, | 303 funElement, |
| 304 new ResolutionRegistry( | 304 new ResolutionRegistry( |
| 305 compiler.backend, new CollectingTreeElements(funElement)), | 305 compiler.backend.target, new CollectingTreeElements(funElement)), |
| 306 scope: new MockTypeVariablesScope(fooElement.buildScope())); | 306 scope: new MockTypeVariablesScope(fooElement.buildScope())); |
| 307 FunctionExpression function = | 307 FunctionExpression function = |
| 308 (funElement as FunctionElementX).parseNode(compiler.parsingContext); | 308 (funElement as FunctionElementX).parseNode(compiler.parsingContext); |
| 309 visitor.visit(function.body); | 309 visitor.visit(function.body); |
| 310 DiagnosticCollector collector = compiler.diagnosticCollector; | 310 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 311 Expect.equals(0, collector.warnings.length); | 311 Expect.equals(0, collector.warnings.length); |
| 312 Expect.equals(1, collector.errors.length); | 312 Expect.equals(1, collector.errors.length); |
| 313 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, | 313 Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| 314 collector.errors.first.message.kind); | 314 collector.errors.first.message.kind); |
| 315 }), | 315 }), |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 collector.clear(); | 614 collector.clear(); |
| 615 | 615 |
| 616 // Add the abstract class to the world and make sure everything is setup | 616 // Add the abstract class to the world and make sure everything is setup |
| 617 // correctly. | 617 // correctly. |
| 618 compiler.parseScript("abstract class Bar {}"); | 618 compiler.parseScript("abstract class Bar {}"); |
| 619 | 619 |
| 620 ResolverVisitor visitor = new ResolverVisitor( | 620 ResolverVisitor visitor = new ResolverVisitor( |
| 621 compiler.resolution, | 621 compiler.resolution, |
| 622 null, | 622 null, |
| 623 new ResolutionRegistry( | 623 new ResolutionRegistry( |
| 624 compiler.backend, new CollectingTreeElements(null))); | 624 compiler.backend.target, new CollectingTreeElements(null))); |
| 625 compiler.resolveStatement("Foo bar;"); | 625 compiler.resolveStatement("Foo bar;"); |
| 626 | 626 |
| 627 ClassElement fooElement = compiler.mainApp.find('Foo'); | 627 ClassElement fooElement = compiler.mainApp.find('Foo'); |
| 628 ClassElement barElement = compiler.mainApp.find('Bar'); | 628 ClassElement barElement = compiler.mainApp.find('Bar'); |
| 629 | 629 |
| 630 Expect.equals(null, barElement.supertype); | 630 Expect.equals(null, barElement.supertype); |
| 631 Expect.isTrue(barElement.interfaces.isEmpty); | 631 Expect.isTrue(barElement.interfaces.isEmpty); |
| 632 | 632 |
| 633 Expect.equals(barElement.computeType(compiler.resolution), | 633 Expect.equals(barElement.computeType(compiler.resolution), |
| 634 fooElement.interfaces.head); | 634 fooElement.interfaces.head); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 compiler.parseScript(script); | 732 compiler.parseScript(script); |
| 733 compiler.resolveStatement(statement); | 733 compiler.resolveStatement(statement); |
| 734 ClassElement classElement = compiler.mainApp.find(className); | 734 ClassElement classElement = compiler.mainApp.find(className); |
| 735 Element element; | 735 Element element; |
| 736 element = classElement.lookupConstructor(constructor); | 736 element = classElement.lookupConstructor(constructor); |
| 737 FunctionExpression tree = (element as FunctionElement).node; | 737 FunctionExpression tree = (element as FunctionElement).node; |
| 738 ResolverVisitor visitor = new ResolverVisitor( | 738 ResolverVisitor visitor = new ResolverVisitor( |
| 739 compiler.resolution, | 739 compiler.resolution, |
| 740 element, | 740 element, |
| 741 new ResolutionRegistry( | 741 new ResolutionRegistry( |
| 742 compiler.backend, new CollectingTreeElements(element)), | 742 compiler.backend.target, new CollectingTreeElements(element)), |
| 743 scope: classElement.buildScope()); | 743 scope: classElement.buildScope()); |
| 744 new InitializerResolver(visitor, element, tree).resolveInitializers(); | 744 new InitializerResolver(visitor, element, tree).resolveInitializers(); |
| 745 visitor.visit(tree.body); | 745 visitor.visit(tree.body); |
| 746 Expect.equals(expectedElementCount, map(visitor).length, | 746 Expect.equals(expectedElementCount, map(visitor).length, |
| 747 "${map(visitor).values} for '$statement' in context of `$script`"); | 747 "${map(visitor).values} for '$statement' in context of `$script`"); |
| 748 | 748 |
| 749 DiagnosticCollector collector = compiler.diagnosticCollector; | 749 DiagnosticCollector collector = compiler.diagnosticCollector; |
| 750 compareWarningKinds(script, expectedWarnings, collector.warnings); | 750 compareWarningKinds(script, expectedWarnings, collector.warnings); |
| 751 compareWarningKinds(script, expectedErrors, collector.errors); | 751 compareWarningKinds(script, expectedErrors, collector.errors); |
| 752 compareWarningKinds(script, expectedInfos, collector.infos); | 752 compareWarningKinds(script, expectedInfos, collector.infos); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 functionName: 'm'); | 1538 functionName: 'm'); |
| 1539 check( | 1539 check( |
| 1540 ''' | 1540 ''' |
| 1541 class A { | 1541 class A { |
| 1542 m() => () => await - 3; | 1542 m() => () => await - 3; |
| 1543 } | 1543 } |
| 1544 main() => new A().m(); | 1544 main() => new A().m(); |
| 1545 ''', | 1545 ''', |
| 1546 className: 'A'); | 1546 className: 'A'); |
| 1547 } | 1547 } |
| OLD | NEW |