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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2954403002: Add type inference for super method invocations. (Closed)
Patch Set: Created 3 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
Index: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
index 8857a2280605a2133fdd5d5c5bb947c6e84ad8db..10cc272f1ef311377fc60b39a25df22429f6c84e 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart
@@ -510,21 +510,23 @@ class KernelDirectMethodInvocation extends DirectMethodInvocation
Expression receiver, Procedure target, Arguments arguments)
: super(receiver, target, arguments);
- KernelDirectMethodInvocation.byReference(
- Expression receiver, Reference targetReference, Arguments arguments)
- : super.byReference(receiver, targetReference, arguments);
-
@override
void _collectDependencies(KernelDependencyCollector collector) {
- // TODO(paulberry): Determine the right thing to do here.
- throw 'TODO(paulberry)';
+ // DirectMethodInvocation can only occur as a result of a use of `super`,
+ // and `super` can't appear inside a field initializer. So this code should
+ // never be reached.
+ internalError(
+ 'Unexpected call to _collectDependencies for DirectMethodInvocation');
}
@override
DartType _inferExpression(
KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
- // TODO(scheglov): implement.
- return typeNeeded ? const DynamicType() : null;
+ inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
+ 'target', new InstrumentationValueForMember(target));
+ return inferrer.inferMethodInvocation(
+ this, receiver, fileOffset, false, typeContext, typeNeeded,
+ interfaceMember: target, methodName: target.name, arguments: arguments);
}
}
@@ -1266,8 +1268,9 @@ class KernelMethodInvocation extends MethodInvocation
@override
DartType _inferExpression(
KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
- return inferrer.inferMethodInvocation(this, receiver, fileOffset, this,
- _isImplicitCall, typeContext, typeNeeded);
+ return inferrer.inferMethodInvocation(
+ this, receiver, fileOffset, _isImplicitCall, typeContext, typeNeeded,
+ desugaredInvocation: this);
}
}
@@ -1321,11 +1324,11 @@ class KernelNullAwareMethodInvocation extends Let implements KernelExpression {
this,
variable.initializer,
fileOffset,
- _desugaredInvocation,
false,
typeContext,
typeNeeded || inferrer.strongMode,
- receiverVariable: variable);
+ receiverVariable: variable,
+ desugaredInvocation: _desugaredInvocation);
if (inferrer.strongMode) {
body.staticType = inferredType;
}
@@ -1787,8 +1790,13 @@ class KernelSuperMethodInvocation extends SuperMethodInvocation
@override
DartType _inferExpression(
KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
- // TODO(scheglov): implement.
- return typeNeeded ? const DynamicType() : null;
+ inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
+ 'target', new InstrumentationValueForMember(interfaceTarget));
+ return inferrer.inferMethodInvocation(this, new KernelThisExpression(),
+ fileOffset, false, typeContext, typeNeeded,
+ interfaceMember: interfaceTarget,
+ methodName: name,
+ arguments: arguments);
}
}

Powered by Google App Engine
This is Rietveld 408576698