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

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

Issue 2900193002: Fix top level type inference in the event that there are circularities. (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
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2cf874fe007cd920cf1737d6659a255585651a49..23ed13955d30d979ffbb537fee3b30cd4ab0354e 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
@@ -130,13 +130,13 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
String getFieldUri(KernelField field);
/// Performs type inference on the given [field].
- void inferField(KernelField field) {
+ void inferField(KernelField field, bool updateType) {
if (fieldHasInitializer(field)) {
var typeInferrer = getFieldTypeInferrer(field);
var type = getFieldDeclaredType(field);
var inferredType = typeInferrer.inferDeclarationType(
typeInferrer.inferFieldInitializer(field, type, type == null));
- if (type == null && strongMode) {
+ if (type == null && strongMode && updateType) {
instrumentation?.record(
Uri.parse(typeInferrer.uri),
getFieldOffset(field),
@@ -159,9 +159,10 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
// TODO(paulberry): report the appropriate error.
if (getFieldDeclaredType(field) == null) {
var uri = getFieldTypeInferrer(field).uri;
+ var inferredType = const DynamicType();
instrumentation?.record(Uri.parse(uri), getFieldOffset(field), 'topType',
- const InstrumentationValueLiteral('circular'));
- setFieldInferredType(field, const DynamicType());
+ new InstrumentationValueForType(inferredType));
+ setFieldInferredType(field, inferredType);
}
}
@@ -192,16 +193,19 @@ class _FieldWalker extends dependencyWalker.DependencyWalker<FieldNode> {
@override
void evaluate(FieldNode f) {
- f._typeInferenceEngine.inferField(f._field);
+ f._typeInferenceEngine.inferField(f._field, true);
}
@override
void evaluateScc(List<FieldNode> scc) {
+ // Mark every field as part of a circularity.
for (var f in scc) {
f._typeInferenceEngine.inferFieldCircular(f._field);
}
+ // Perform type inference on the initializers of every field, but don't
+ // update the inferred types.
for (var f in scc) {
- f._typeInferenceEngine.inferField(f._field);
+ f._typeInferenceEngine.inferField(f._field, false);
}
}
}
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/strong.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698