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

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

Issue 2839193003: Rename TypeInferrerImpl._context to _closureContext; make `null` outside of closures. (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/front_end/front_end.iml ('k') | no next file » | 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_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 a3f88f5b5e3a301bf4b8547f1c93de61459caeed..276d0e545a7403e5ef54cf2d985932fd7e00eba5 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
@@ -61,18 +61,14 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
final Instrumentation instrumentation;
- _InferenceContext _context;
+ /// Context information for the current closure, or `null` if we are not
+ /// inside a closure.
+ _ClosureContext _closureContext;
TypeInferrerImpl(TypeInferenceEngineImpl<F> engine, this.uri)
: coreTypes = engine.coreTypes,
strongMode = engine.strongMode,
- instrumentation = engine.instrumentation {
- // The return type only needs to be inferred for closures, so we can safely
- // set isAsync and isGenerator to false in the outermost context.
- // TODO(paulberry): this seems brittle. Would it be better to leave
- // _context as `null` here?
- _context = new _InferenceContext(false, false);
- }
+ instrumentation = engine.instrumentation;
/// Gets the type promoter that should be used to promote types during
/// inference.
@@ -135,12 +131,12 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
// node's return type if it uses expression syntax. Does that make sense
// for Dart 2.0?
bool needToSetReturnType = isExpressionFunction;
- _InferenceContext oldContext = _context;
- _context = new _InferenceContext(isAsync, isGenerator);
+ _ClosureContext oldClosureContext = _closureContext;
+ _closureContext = new _ClosureContext(isAsync, isGenerator);
inferStatement(body);
DartType inferredReturnType;
if (needToSetReturnType || typeNeeded) {
- inferredReturnType = _context.inferredReturnType;
+ inferredReturnType = _closureContext.inferredReturnType;
if (isAsync) {
inferredReturnType = new InterfaceType(
coreTypes.futureClass, <DartType>[inferredReturnType]);
@@ -151,7 +147,7 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
new InstrumentationValueForType(inferredReturnType));
setReturnType(inferredReturnType);
}
- _context = oldContext;
+ _closureContext = oldClosureContext;
if (typeNeeded) {
return getFunctionType();
} else {
@@ -243,14 +239,14 @@ abstract class TypeInferrerImpl<S, E, V, F> extends TypeInferrer<S, E, V, F> {
/// Keeps track of information about the innermost function or closure being
/// inferred.
-class _InferenceContext {
+class _ClosureContext {
final bool isAsync;
final bool isGenerator;
DartType _inferredReturnType;
- _InferenceContext(this.isAsync, this.isGenerator);
+ _ClosureContext(this.isAsync, this.isGenerator);
/// Gets the return type that was inferred for the current closure.
get inferredReturnType {
« no previous file with comments | « pkg/front_end/front_end.iml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698