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

Unified Diff: pkg/compiler/lib/src/resolution/scope.dart

Issue 2112503002: Implement super in mixins. (Closed) Base URL: sso://user/ahe/dart-sdk@malformed
Patch Set: Remove experimenting code. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/scope.dart
diff --git a/pkg/compiler/lib/src/resolution/scope.dart b/pkg/compiler/lib/src/resolution/scope.dart
index 41df8033f6ef8b6710d5d7f0ab20b202471393f4..ecc7c1fc2061d5d268eb60d34e46380b78d34b6b 100644
--- a/pkg/compiler/lib/src/resolution/scope.dart
+++ b/pkg/compiler/lib/src/resolution/scope.dart
@@ -173,3 +173,41 @@ class LibraryScope implements Scope {
String toString() => 'LibraryScope($library)';
}
+
+/// A mixin application scope.
+///
+/// This scope is slightly different from a regular [ClassScope] as we copy
+/// methods from the mixin into the mixin application. Firstly, the parent
+/// scope is the mixin (and its library scope). Secondly, since a mixin
+/// application can have more type variables than the mixin, we need to ensure
+/// we only return the ones defined in the mixin (by overriding
+/// [lookupTypeVariable]). See [ClassResolverVisitor.applyMixin] for details.
+class MixinApplicationScope extends ClassScope {
+ MixinApplicationElement get element => super.element;
+
+ MixinApplicationScope(Scope parentScope, MixinApplicationElement element)
+ : super(parentScope, element);
+
+ @override
+ Element lookupTypeVariable(String name) {
+ List<DartType> typeVariables = element.mixin?.typeVariables;
+ if (typeVariables == null) return null;
+ int index = 0;
+ for (TypeVariableType type in typeVariables) {
+ if (type.name == name) return element.typeVariables[index].element;
+ index++;
+ }
+ return null;
+ }
+}
+
+/// An empty scope, used for error recovery.
+class NoScope extends Scope {
+ @override
+ Element add(Element element) {
+ throw "Cannot add an element to a no-scope";
+ }
+
+ @override
+ Element lookup(String name) => null;
+}
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698