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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 2935783003: Add type inference for assignments to `super[...]` (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/type_inference/type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index ceddac428b49d3beb1a46617614ff907f9ac5ff8..344851102078e9336c4436672b256e80337c4714 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -25,6 +25,7 @@ import 'package:kernel/ast.dart'
FunctionType,
Initializer,
InterfaceType,
+ InvocationExpression,
Member,
MethodInvocation,
Name,
@@ -33,6 +34,7 @@ import 'package:kernel/ast.dart'
PropertyGet,
PropertySet,
Statement,
+ SuperMethodInvocation,
SuperPropertyGet,
SuperPropertySet,
TypeParameterType,
@@ -266,19 +268,34 @@ abstract class TypeInferrerImpl extends TypeInferrer {
/// Finds a member of [receiverType] called [name], and if it is found,
/// reports it through instrumentation and records it in [methodInvocation].
Member findMethodInvocationMember(
- DartType receiverType, MethodInvocation methodInvocation,
+ DartType receiverType, InvocationExpression methodInvocation,
{bool silent: false}) {
- var interfaceMember = findInterfaceMember(
- receiverType, methodInvocation.name, methodInvocation.fileOffset,
- silent: silent);
- methodInvocation.interfaceTarget = interfaceMember;
- return interfaceMember;
+ // TODO(paulberry): could we add getters to InvocationExpression to make
+ // these is-checks unnecessary?
+ if (methodInvocation is MethodInvocation) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, methodInvocation.name, methodInvocation.fileOffset,
+ silent: silent);
+ methodInvocation.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else if (methodInvocation is SuperMethodInvocation) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, methodInvocation.name, methodInvocation.fileOffset,
+ silent: silent);
+ methodInvocation.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else {
+ throw internalError(
+ 'Unexpected invocation type: ${methodInvocation.runtimeType}');
+ }
}
/// Finds a member of [receiverType] called [name], and if it is found,
/// reports it through instrumentation and records it in [propertyGet].
Member findPropertyGetMember(DartType receiverType, Expression propertyGet,
{bool silent: false}) {
+ // TODO(paulberry): could we add a common base class to PropertyGet and
+ // SuperPropertyGet to make these is-checks unnecessary?
if (propertyGet is PropertyGet) {
var interfaceMember = findInterfaceMember(
receiverType, propertyGet.name, propertyGet.fileOffset,

Powered by Google App Engine
This is Rietveld 408576698