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

Unified Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 2114653004: Correct lookup scope for subclasses of mixin application. (Closed) Base URL: sso://user/ahe/dart-sdk@enable_type_checker
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/elements/modelx.dart
diff --git a/pkg/compiler/lib/src/elements/modelx.dart b/pkg/compiler/lib/src/elements/modelx.dart
index 2bd0ef9bfb194ed3ea8ae6c02e6168accd8a8e2f..128f56e9e7d351acbaac026e2d34b0deb5fff1b5 100644
--- a/pkg/compiler/lib/src/elements/modelx.dart
+++ b/pkg/compiler/lib/src/elements/modelx.dart
@@ -2846,6 +2846,8 @@ abstract class MixinApplicationElementX extends BaseClassElementX
InterfaceType mixinType;
+ final ScopeX localScope = new ScopeX();
+
MixinApplicationElementX(String name, Element enclosing, int id)
: super(name, enclosing, id, STATE_NOT_STARTED);
@@ -2853,7 +2855,9 @@ abstract class MixinApplicationElementX extends BaseClassElementX
bool get isMixinApplication => true;
bool get hasConstructor => !constructors.isEmpty;
- bool get hasLocalScopeMembers => !constructors.isEmpty;
+ bool get hasLocalScopeMembers {
+ return constructors.isNotEmpty || members.isNotEmpty;
+ }
get patch => null;
get origin => null;
@@ -2866,10 +2870,11 @@ abstract class MixinApplicationElementX extends BaseClassElementX
void addMember(Element element, DiagnosticReporter reporter) {
members = members.prepend(element);
+ addToScope(element, reporter);
}
void addToScope(Element element, DiagnosticReporter reporter) {
- reporter.internalError(this, 'Cannot add to scope of $this.');
+ localScope.add(element, reporter);
}
void addConstructor(FunctionElement constructor) {
@@ -2910,6 +2915,13 @@ abstract class MixinApplicationElementX extends BaseClassElementX
}
return new MixinApplicationScope(parentScope, this);
}
+
+ Element localLookup(String name) {
+ for (Link<Element> link = constructors; !link.isEmpty; link = link.tail) {
+ if (link.head.name == name) return link.head;
+ }
+ return localScope.lookup(name);
+ }
}
class NamedMixinApplicationElementX extends MixinApplicationElementX
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698