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

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

Issue 2919623002: Implement type inference for PropertySet. (Closed)
Patch Set: Created 3 years, 7 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 545ee2768340bc423518a94c4eec87bcdbf5ecda..323fc6a21c453aebcf19fd0e1beced49915f792b 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
@@ -1196,8 +1196,28 @@ class KernelPropertySet extends PropertySet implements KernelExpression {
@override
DartType _inferExpression(
KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
- // TODO(scheglov): implement.
- return typeNeeded ? const DynamicType() : null;
+ typeNeeded =
+ inferrer.listener.propertySetEnter(this, typeContext) || typeNeeded;
+ // First infer the receiver so we can look up the setter that was invoked.
+ var receiverType = inferrer.inferExpression(receiver, null, true);
+ Member interfaceMember;
+ if (receiverType is InterfaceType) {
+ interfaceMember = inferrer.classHierarchy
+ .getInterfaceMember(receiverType.classNode, name, setter: true);
+ // Our non-strong golden files currently don't include interface targets,
+ // so we can't store the interface target without causing tests to fail.
+ // TODO(paulberry): fix this.
+ if (inferrer.strongMode) {
+ inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
+ 'target', new InstrumentationValueForMember(interfaceMember));
+ interfaceTarget = interfaceMember;
+ }
+ }
+ var setterType =
+ inferrer.getSetterType(interfaceMember, receiverType, name);
+ var inferredType = inferrer.inferExpression(value, setterType, typeNeeded);
+ inferrer.listener.propertySetExit(this, inferredType);
+ return typeNeeded ? inferredType : null;
}
}

Powered by Google App Engine
This is Rietveld 408576698