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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart

Issue 913213002: Handle super calls to fields or getters that look like method calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 5 years, 10 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/cps_ir/cps_ir_builder_visitor.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart
index ea7bf3a1fe80c63bc88acd16a83908be7d0c4354..492f1170833e9b4ae229a06f4d029581b42209d9 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart
@@ -758,15 +758,39 @@ abstract class IrBuilderVisitor extends ResolvedVisitor<ir.Primitive>
ir.Primitive visitSuperSend(ast.Send node) {
assert(irBuilder.isOpen);
- if (node.isPropertyAccess) {
- return visitGetterSend(node);
- } else {
- Selector selector = elements.getSelector(node);
- Element target = elements[node];
+ Selector selector = elements.getSelector(node);
+ Element target = elements[node];
+
+ if (selector.isCall && (target.isGetter || target.isField)) {
+ // We are invoking a field or getter as if it was a method, e.g:
+ //
+ // class A { get foo => {..} }
+ // class B extends A {
+ // m() {
+ // super.foo(1, 2, 3); }
+ // }
+ // }
+ //
+ // We invoke the getter of 'foo' and then invoke the 'call' method on
+ // the result, using the given arguments.
+ Selector getter = new Selector.getterFrom(selector);
+ Selector call = new Selector.callClosureFrom(selector);
+ ir.Primitive receiver =
+ irBuilder.buildSuperInvocation(target, getter, []);
List<ir.Primitive> arguments = node.arguments.mapToList(visit);
- if (selector.isCall) {
- arguments = normalizeStaticArguments(selector, target, arguments);
- }
+ arguments = normalizeDynamicArguments(selector, arguments);
+ return irBuilder.buildCallInvocation(receiver, call, arguments);
+ } else if (selector.isCall) {
+ // We are invoking a method.
+ assert(target is FunctionElement);
+ List<ir.Primitive> arguments = node.arguments.mapToList(visit);
+ arguments = normalizeStaticArguments(selector, target, arguments);
+ return irBuilder.buildSuperInvocation(target, selector, arguments);
+ } else {
+ // We are invoking a getter, operator, indexer, etc.
+ List<ir.Primitive> arguments = node.argumentsNode == null
+ ? <ir.Primitive>[]
+ : node.arguments.mapToList(visit);
return irBuilder.buildSuperInvocation(target, selector, arguments);
}
}
« 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