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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 11688010: NoSuchMethod on different super accesses/invocations handled. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 277be1e64bbff78bb51e8cc6782a6cef8886a738..8402d3c4699a9839a274febe9e111d8cbac76cf8 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3133,23 +3133,26 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
generateSuperNoSuchMethodSend(Send node) {
Selector selector = elements.getSelector(node);
- SourceString name = selector.name;
-
+ String name = selector.invocationMirrorMemberName;
ClassElement cls = work.element.getEnclosingClass();
+ if (cls is ClosureClassElement) {
+ ClosureClassElement closureClass = cls;
+ cls = closureClass.methodElement.getEnclosingClass();
+ }
Element element = cls.lookupSuperMember(Compiler.NO_SUCH_METHOD);
if (element.enclosingElement.declaration != compiler.objectClass) {
// Register the call as dynamic if [:noSuchMethod:] on the super class
// is _not_ the default implementation from [:Object:].
- compiler.enqueuer.codegen.registerDynamicInvocation(name, selector);
+ compiler.enqueuer.codegen.registerDynamicInvocation(selector.name,
+ selector);
}
HStatic target = new HStatic(element);
add(target);
HInstruction self = localsHandler.readThis();
Constant nameConstant = constantSystem.createString(
- new DartString.literal(name.slowToString()), node);
+ new DartString.literal(name), node);
- String internalName = backend.namer.instanceMethodInvocationName(
- currentLibrary, name, selector);
+ String internalName = backend.namer.invocationMirrorInternalName(selector);
Constant internalNameConstant =
constantSystem.createString(new DartString.literal(internalName), node);
@@ -3209,7 +3212,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
add(target);
var inputs = <HInstruction>[target, context];
if (node.isPropertyAccess) {
- push(new HInvokeSuper(inputs));
+ push(new HInvokeSuper(inputs, isGetter: true));
} else if (element.isFunction() || element.isGenerativeConstructor()) {
// TODO(5347): Try to avoid the need for calling [implementation] before
// calling [addStaticSendArgumentsToList].
@@ -3217,7 +3220,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
bool succeeded = addStaticSendArgumentsToList(selector, node.arguments,
function, inputs);
if (!succeeded) {
- generateWrongArgumentCountError(node, element, node.arguments);
+ generateSuperNoSuchMethodSend(node);
} else {
push(new HInvokeSuper(inputs));
}
@@ -3644,7 +3647,24 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
Operator op = node.assignmentOperator;
if (node.isSuperCall) {
- if (element == null) return generateSuperNoSuchMethodSend(node);
+ bool assignable = true;
ngeoffray 2012/12/28 10:24:03 Maybe a Elements.isAssignable helper method could
Johnni Winther 2012/12/28 22:32:31 Done.
+ if (element == null) {
+ assignable = false;
+ } else if (element.isFunction()) {
+ assignable = false;
+ } else if (element.isField()) {
+ if (element.modifiers.isFinalOrConst()) {
+ assignable = false;
+ }
+ } else if (element.isAbstractField()) {
+ AbstractFieldElement abstractFieldElement = element;
+ if (abstractFieldElement.setter == null) {
+ assignable = false;
+ }
+ }
+ if (!assignable) {
+ return generateSuperNoSuchMethodSend(node);
+ }
HInstruction target = new HStatic(element);
HInstruction context = localsHandler.readThis();
add(target);

Powered by Google App Engine
This is Rietveld 408576698