Chromium Code Reviews| Index: tests/compiler/dart2js/mock_compiler.dart |
| diff --git a/tests/compiler/dart2js/mock_compiler.dart b/tests/compiler/dart2js/mock_compiler.dart |
| index 839c0836978295477bf4ddd274caa8bc21efbdb8..1d114f4d3cd290d4027f11c3c605944628086272 100644 |
| --- a/tests/compiler/dart2js/mock_compiler.dart |
| +++ b/tests/compiler/dart2js/mock_compiler.dart |
| @@ -11,6 +11,7 @@ import 'package:compiler/compiler.dart' as api; |
| import 'package:compiler/src/common/names.dart' show |
| Uris; |
| import 'package:compiler/src/constants/expressions.dart'; |
| +import 'package:compiler/src/dart_types.dart' show DartType; |
| import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; |
| import 'package:compiler/src/diagnostics/source_span.dart'; |
| import 'package:compiler/src/diagnostics/spannable.dart'; |
| @@ -224,10 +225,15 @@ class MockCompiler extends Compiler { |
| TreeElementMapping resolveNodeStatement(Node tree, |
| ExecutableElement element) { |
| ResolverVisitor visitor = |
| - new ResolverVisitor(this, element, |
| + new ResolverVisitor( |
| + this, |
| + element, |
| new ResolutionRegistry(this, |
| - new CollectingTreeElements(element))); |
| - if (visitor.scope is LibraryScope) { |
| + new CollectingTreeElements(element)), |
| + scope: new MockTypeVariablesScope( |
|
Johnni Winther
2016/04/29 07:21:06
Why is this necessary?
eernst
2016/04/29 13:24:50
I managed to remove one of the two usages of this
|
| + element.enclosingElement.buildScope())); |
| + if (visitor.scope is LibraryScope || |
| + visitor.scope is MockTypeVariablesScope) { |
| visitor.scope = new MethodScope(visitor.scope, element); |
| } |
| visitor.visit(tree); |
| @@ -238,9 +244,13 @@ class MockCompiler extends Compiler { |
| resolverVisitor() { |
| Element mockElement = new MockElement(mainApp.entryCompilationUnit); |
| ResolverVisitor visitor = |
| - new ResolverVisitor(this, mockElement, |
| - new ResolutionRegistry(this, |
| - new CollectingTreeElements(mockElement))); |
| + new ResolverVisitor( |
| + this, |
| + mockElement, |
| + new ResolutionRegistry( |
| + this, new CollectingTreeElements(mockElement)), |
| + scope: new MockTypeVariablesScope( |
| + mockElement.enclosingElement.buildScope())); |
| visitor.scope = new MethodScope(visitor.scope, mockElement); |
| return visitor; |
| } |
| @@ -321,6 +331,13 @@ class CollectingTreeElements extends TreeElementMapping { |
| } |
| } |
| +class MockTypeVariablesScope extends TypeVariablesScope { |
| + @override |
| + List<DartType> get typeVariables => <DartType>[]; |
| + MockTypeVariablesScope(Scope parent) : super(parent); |
| + String toString() => 'MockTypeVariablesScope($parent)'; |
| +} |
| + |
| // The mock compiler does not split the program in output units. |
| class MockDeferredLoadTask extends DeferredLoadTask { |
| MockDeferredLoadTask(Compiler compiler) : super(compiler); |