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..59dc3da662f808682378ca42f4187823349eae3f 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( |
+ 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,12 @@ 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: mockElement.enclosingElement.buildScope()); |
visitor.scope = new MethodScope(visitor.scope, mockElement); |
return visitor; |
} |
@@ -321,6 +330,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); |