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

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

Issue 2921443002: Implement type inference for PropertyGet. (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 04b9a20195fcbf36e2fa20b2e7a4b68916b4672c..34a4bdc3d0dc16a81eafffa0f66325d15a8090e4 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
@@ -1076,7 +1076,7 @@ class KernelMethodInvocation extends MethodInvocation
// to fail. TODO(paulberry): fix this.
if (inferrer.strongMode) {
inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
- 'target', new InstrumentationValueForProcedure(interfaceMember));
+ 'target', new InstrumentationValueForMember(interfaceMember));
interfaceTarget = interfaceMember;
}
isOverloadedArithmeticOperator = inferrer.typeSchemaEnvironment
@@ -1156,8 +1156,28 @@ class KernelPropertyGet extends PropertyGet implements KernelExpression {
@override
DartType _inferExpression(
KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
- // TODO(scheglov): implement.
- return typeNeeded ? const DynamicType() : null;
+ typeNeeded =
+ inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded;
+ // First infer the receiver so we can look up the getter that was invoked.
+ var receiverType = inferrer.inferExpression(receiver, null, true);
+ Member interfaceMember;
+ if (receiverType is InterfaceType) {
+ interfaceMember = inferrer.classHierarchy
+ .getInterfaceMember(receiverType.classNode, name);
+ // 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 inferredType =
+ inferrer.getCalleeType(interfaceMember, receiverType, name);
+ // TODO(paulberry): Infer tear-off type arguments if appropriate.
+ inferrer.listener.propertyGetExit(this, inferredType);
+ return typeNeeded ? inferredType : null;
}
}
@@ -1888,10 +1908,6 @@ class KernelYieldStatement extends YieldStatement implements KernelStatement {
}
class _UnfinishedCascade extends Expression {
- getStaticType(types) {
- return internalError("Internal error: Unsupported operation.");
- }
-
accept(v) {
return internalError("Internal error: Unsupported operation.");
}
@@ -1900,11 +1916,15 @@ class _UnfinishedCascade extends Expression {
return internalError("Internal error: Unsupported operation.");
}
- visitChildren(v) {
+ getStaticType(types) {
return internalError("Internal error: Unsupported operation.");
}
transformChildren(v) {
return internalError("Internal error: Unsupported operation.");
}
+
+ visitChildren(v) {
+ return internalError("Internal error: Unsupported operation.");
+ }
}

Powered by Google App Engine
This is Rietveld 408576698