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

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

Issue 2905123002: Perform type inference on explicitly typed fields. (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/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 544a8aa9ffcc286ad2eed97aef87c173ef475b61..12bca4c8b868d10da639f6f28cec80a1279d3d11 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
@@ -149,6 +149,9 @@ abstract class TypeInferrer {
/// Gets the [FieldNode] corresponding to the given [readTarget], if any.
FieldNode getFieldNodeForReadTarget(Member readTarget);
+ /// Performs full type inference on the given field initializer.
+ void inferFieldInitializer(DartType declaredType, Expression initializer);
+
/// Performs type inference on the given function body.
void inferFunctionBody(
DartType returnType, AsyncMarker asyncMarker, Statement body);
@@ -187,11 +190,12 @@ abstract class TypeInferrerImpl extends TypeInferrer {
/// inside a closure.
ClosureContext closureContext;
- TypeInferrerImpl(TypeInferenceEngineImpl engine, this.uri, this.listener)
+ TypeInferrerImpl(
+ TypeInferenceEngineImpl engine, this.uri, this.listener, bool topLevel)
: coreTypes = engine.coreTypes,
strongMode = engine.strongMode,
classHierarchy = engine.classHierarchy,
- instrumentation = engine.instrumentation,
+ instrumentation = topLevel ? null : engine.instrumentation,
typeSchemaEnvironment = engine.typeSchemaEnvironment;
/// Gets the type promoter that should be used to promote types during
@@ -300,11 +304,17 @@ abstract class TypeInferrerImpl extends TypeInferrer {
DartType inferExpression(
Expression expression, DartType typeContext, bool typeNeeded);
+ @override
+ void inferFieldInitializer(DartType declaredType, Expression initializer) {
+ assert(closureContext == null);
+ inferExpression(initializer, declaredType, false);
+ }
+
/// Performs type inference on the given [field]'s initializer expression.
///
/// Derived classes should provide an implementation that calls
/// [inferExpression] for the given [field]'s initializer expression.
- DartType inferFieldInitializer(
+ DartType inferFieldTopLevel(
KernelField field, DartType type, bool typeNeeded);
@override
« no previous file with comments | « pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart ('k') | pkg/front_end/test/fasta/kompile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698