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

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

Issue 2931363003: Add type inference for assignments to properties. (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 63cf51c34f02a9b47cf6590698db3c8f63631fa8..e88de480c0ca4610e605687347c063b78704861c 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
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE.md file.
import 'package:front_end/src/base/instrumentation.dart';
+import 'package:front_end/src/fasta/errors.dart' show internalError;
import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart';
import 'package:front_end/src/fasta/names.dart' show callName;
import 'package:front_end/src/fasta/type_inference/type_inference_engine.dart';
@@ -29,7 +30,11 @@ import 'package:kernel/ast.dart'
Name,
Procedure,
ProcedureKind,
+ PropertyGet,
+ PropertySet,
Statement,
+ SuperPropertyGet,
+ SuperPropertySet,
TypeParameterType,
VoidType;
import 'package:kernel/class_hierarchy.dart';
@@ -258,6 +263,50 @@ abstract class TypeInferrerImpl extends TypeInferrer {
return null;
}
+ /// 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}) {
+ if (propertyGet is PropertyGet) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, propertyGet.name, propertyGet.fileOffset,
+ silent: silent);
+ propertyGet.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else if (propertyGet is SuperPropertyGet) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, propertyGet.name, propertyGet.fileOffset,
+ silent: silent);
+ propertyGet.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else {
+ throw internalError(
+ 'Unexpected propertyGet type: ${propertyGet.runtimeType}');
+ }
+ }
+
+ /// Finds a member of [receiverType] called [name], and if it is found,
+ /// reports it through instrumentation and records it in [propertySet].
+ Member findPropertySetMember(DartType receiverType, Expression propertySet,
+ {bool silent: false}) {
+ if (propertySet is PropertySet) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, propertySet.name, propertySet.fileOffset,
+ setter: true, silent: silent);
+ propertySet.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else if (propertySet is SuperPropertySet) {
+ var interfaceMember = findInterfaceMember(
+ receiverType, propertySet.name, propertySet.fileOffset,
+ setter: true, silent: silent);
+ propertySet.interfaceTarget = interfaceMember;
+ return interfaceMember;
+ } else {
+ throw internalError(
+ 'Unexpected propertySet type: ${propertySet.runtimeType}');
+ }
+ }
+
/// Finds a member of [receiverType] called [name], and if it is found,
/// reports it through instrumentation and records it in [methodInvocation].
Member findMethodInvocationMember(

Powered by Google App Engine
This is Rietveld 408576698