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

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

Issue 2946733003: Fix type inference of getters that "override" setters and vice versa. (Closed)
Patch Set: Address code review comments 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_inference_engine.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
index ee4166216ede6c53cb54d942acab19886ed6dfb4..54d61a4acb0d0c949a700bc56bb801bf929cbdf0 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart
@@ -39,8 +39,12 @@ class FieldNode extends dependencyWalker.Node<FieldNode> {
final overrides = <Member>[];
+ final crossOverrides = <Member>[];
+
FieldNode(this._typeInferenceEngine, this.member);
+ get candidateOverrides => overrides.isNotEmpty ? overrides : crossOverrides;
+
@override
bool get isEvaluated => state == FieldState.Inferred;
@@ -158,10 +162,10 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
List<FieldNode> computeFieldDependencies(FieldNode fieldNode) {
// If the field's type is going to be determined by inheritance, then its
// dependencies are determined by inheritance too.
- if (fieldNode.overrides.isNotEmpty) {
+ var candidateOverrides = fieldNode.candidateOverrides;
+ if (candidateOverrides.isNotEmpty) {
var dependencies = <FieldNode>[];
- for (var override in fieldNode.overrides) {
- // TODO(paulberry): support dependencies on getters/setters too.
+ for (var override in candidateOverrides) {
var dep = KernelMember.getFieldNode(override);
if (dep != null) dependencies.add(dep);
}
@@ -335,7 +339,7 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
DartType tryInferFieldByInheritance(FieldNode fieldNode) {
DartType inferredType;
- for (var override in fieldNode.overrides) {
+ for (var override in fieldNode.candidateOverrides) {
var nextInferredType = _computeOverriddenFieldType(override, fieldNode);
if (inferredType == null) {
inferredType = nextInferredType;

Powered by Google App Engine
This is Rietveld 408576698