Skip to content

Commit 1d8bef0

Browse files
Kevin Millikincommit-bot@chromium.org
Kevin Millikin
authored andcommitted
Remove class TypeInferenceEngineImpl
The abstract class TypeInferenceEngineImpl does not really serve any purpose, so remove it. If nothing else, it makes it easier to understand what is going on and change things. Change-Id: I9aabcb041b3fbc7d5b7b63dfef9effeb73a6bab8 Reviewed-on: https://dart-review.googlesource.com/57822 Reviewed-by: Peter von der Ahé <[email protected]> Commit-Queue: Kevin Millikin <[email protected]>
1 parent dd83e69 commit 1d8bef0

File tree

4 files changed

+35
-72
lines changed

4 files changed

+35
-72
lines changed

pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ import '../type_inference/type_inference_engine.dart'
5151
FieldInitializerInferenceNode,
5252
IncludesTypeParametersCovariantly,
5353
InferenceNode,
54-
TypeInferenceEngine,
55-
TypeInferenceEngineImpl;
54+
TypeInferenceEngine;
5655

5756
import '../type_inference/type_inferrer.dart'
5857
show TypeInferrer, TypeInferrerDisabled, TypeInferrerImpl;
@@ -819,7 +818,7 @@ class ShadowField extends Field implements ShadowMember {
819818

820819
@override
821820
void setInferredType(
822-
TypeInferenceEngineImpl engine, Uri uri, DartType inferredType) {
821+
TypeInferenceEngine engine, Uri uri, DartType inferredType) {
823822
type = inferredType;
824823
}
825824

@@ -1434,7 +1433,7 @@ abstract class ShadowMember implements Member {
14341433
void set _inferenceNode(InferenceNode value);
14351434

14361435
void setInferredType(
1437-
TypeInferenceEngineImpl engine, Uri uri, DartType inferredType);
1436+
TypeInferenceEngine engine, Uri uri, DartType inferredType);
14381437

14391438
static void resolveInferenceNode(Member member) {
14401439
if (member is ShadowMember) {
@@ -1580,7 +1579,7 @@ class ShadowProcedure extends Procedure implements ShadowMember {
15801579

15811580
@override
15821581
void setInferredType(
1583-
TypeInferenceEngineImpl engine, Uri uri, DartType inferredType) {
1582+
TypeInferenceEngine engine, Uri uri, DartType inferredType) {
15841583
if (isSetter) {
15851584
if (function.positionalParameters.length > 0) {
15861585
function.positionalParameters[0].type = inferredType;
@@ -2027,7 +2026,7 @@ class ShadowTryFinally extends TryFinally implements ShadowStatement {
20272026

20282027
/// Concrete implementation of [TypeInferenceEngine] specialized to work with
20292028
/// kernel objects.
2030-
class ShadowTypeInferenceEngine extends TypeInferenceEngineImpl {
2029+
class ShadowTypeInferenceEngine extends TypeInferenceEngine {
20312030
ShadowTypeInferenceEngine(Instrumentation instrumentation, bool strongMode)
20322031
: super(instrumentation, strongMode);
20332032

pkg/front_end/lib/src/fasta/type_inference/interface_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ class ForwardingNode extends Procedure {
610610
/// infer covariance annotations, and to create forwarwding stubs when necessary
611611
/// to meet covariance requirements.
612612
class InterfaceResolver {
613-
final TypeInferenceEngineImpl _typeInferenceEngine;
613+
final TypeInferenceEngine _typeInferenceEngine;
614614

615615
final TypeEnvironment _typeEnvironment;
616616

pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart

Lines changed: 27 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import 'type_schema_environment.dart';
3737
/// Concrete class derived from [InferenceNode] to represent type inference of a
3838
/// field based on its initializer.
3939
class FieldInitializerInferenceNode extends InferenceNode {
40-
final TypeInferenceEngineImpl _typeInferenceEngine;
40+
final TypeInferenceEngine _typeInferenceEngine;
4141

4242
/// The field whose type should be inferred.
4343
final ShadowField field;
@@ -200,16 +200,24 @@ abstract class InferenceNode {
200200
/// (e.g. DietListener). Derived classes should derive from
201201
/// [TypeInferenceEngineImpl].
202202
abstract class TypeInferenceEngine {
203-
ClassHierarchy get classHierarchy;
204-
205-
void set classHierarchy(ClassHierarchy classHierarchy);
203+
ClassHierarchy classHierarchy;
206204

207-
CoreTypes get coreTypes;
205+
CoreTypes coreTypes;
208206

209207
/// Indicates whether the "prepare" phase of type inference is complete.
210-
void set isTypeInferencePrepared(bool value);
208+
bool isTypeInferencePrepared = false;
209+
210+
TypeSchemaEnvironment typeSchemaEnvironment;
211+
212+
final staticInferenceNodes = <FieldInitializerInferenceNode>[];
213+
214+
final initializingFormals = <ShadowVariableDeclaration>[];
215+
216+
final Instrumentation instrumentation;
217+
218+
final bool strongMode;
211219

212-
TypeSchemaEnvironment get typeSchemaEnvironment;
220+
TypeInferenceEngine(this.instrumentation, this.strongMode);
213221

214222
/// Creates a disabled type inferrer (intended for debugging and profiling
215223
/// only).
@@ -225,66 +233,23 @@ abstract class TypeInferenceEngine {
225233
TypeInferrer createTopLevelTypeInferrer(
226234
InterfaceType thisType, ShadowField field);
227235

236+
/// Retrieve the [TypeInferrer] for the given [field], which was created by
237+
/// a previous call to [createTopLevelTypeInferrer].
238+
TypeInferrerImpl getFieldTypeInferrer(ShadowField field);
239+
228240
/// Performs the second phase of top level initializer inference, which is to
229241
/// visit all accessors and top level variables that were passed to
230242
/// [recordAccessor] in topologically-sorted order and assign their types.
231-
void finishTopLevelFields();
232-
233-
/// Performs the third phase of top level inference, which is to visit all
234-
/// initializing formals and infer their types (if necessary) from the
235-
/// corresponding fields.
236-
void finishTopLevelInitializingFormals();
237-
238-
/// Gets ready to do top level type inference for the component having the
239-
/// given [hierarchy], using the given [coreTypes].
240-
void prepareTopLevel(CoreTypes coreTypes, ClassHierarchy hierarchy);
241-
242-
/// Records that the given initializing [formal] will need top level type
243-
/// inference.
244-
void recordInitializingFormal(ShadowVariableDeclaration formal);
245-
246-
/// Records that the given static [field] will need top level type inference.
247-
void recordStaticFieldInferenceCandidate(
248-
ShadowField field, LibraryBuilder library);
249-
}
250-
251-
/// Derived class containing generic implementations of
252-
/// [TypeInferenceEngineImpl].
253-
///
254-
/// This class contains as much of the implementation of type inference as
255-
/// possible without knowing the identity of the type parameter. It defers to
256-
/// abstract methods for everything else.
257-
abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
258-
final Instrumentation instrumentation;
259-
260-
final bool strongMode;
261-
262-
final staticInferenceNodes = <FieldInitializerInferenceNode>[];
263-
264-
final initializingFormals = <ShadowVariableDeclaration>[];
265-
266-
@override
267-
CoreTypes coreTypes;
268-
269-
@override
270-
ClassHierarchy classHierarchy;
271-
272-
TypeSchemaEnvironment typeSchemaEnvironment;
273-
274-
@override
275-
bool isTypeInferencePrepared = false;
276-
277-
TypeInferenceEngineImpl(this.instrumentation, this.strongMode);
278-
279-
@override
280243
void finishTopLevelFields() {
281244
for (var node in staticInferenceNodes) {
282245
node.resolve();
283246
}
284247
staticInferenceNodes.clear();
285248
}
286249

287-
@override
250+
/// Performs the third phase of top level inference, which is to visit all
251+
/// initializing formals and infer their types (if necessary) from the
252+
/// corresponding fields.
288253
void finishTopLevelInitializingFormals() {
289254
for (ShadowVariableDeclaration formal in initializingFormals) {
290255
try {
@@ -300,23 +265,22 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine {
300265
}
301266
}
302267

303-
/// Retrieve the [TypeInferrer] for the given [field], which was created by
304-
/// a previous call to [createTopLevelTypeInferrer].
305-
TypeInferrerImpl getFieldTypeInferrer(ShadowField field);
306-
307-
@override
268+
/// Gets ready to do top level type inference for the component having the
269+
/// given [hierarchy], using the given [coreTypes].
308270
void prepareTopLevel(CoreTypes coreTypes, ClassHierarchy hierarchy) {
309271
this.coreTypes = coreTypes;
310272
this.classHierarchy = hierarchy;
311273
this.typeSchemaEnvironment =
312274
new TypeSchemaEnvironment(coreTypes, hierarchy, strongMode);
313275
}
314276

315-
@override
277+
/// Records that the given initializing [formal] will need top level type
278+
/// inference.
316279
void recordInitializingFormal(ShadowVariableDeclaration formal) {
317280
initializingFormals.add(formal);
318281
}
319282

283+
/// Records that the given static [field] will need top level type inference.
320284
void recordStaticFieldInferenceCandidate(
321285
ShadowField field, LibraryBuilder library) {
322286
var node = new FieldInitializerInferenceNode(this, field, library);

pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import 'interface_resolver.dart' show ForwardingNode, SyntheticAccessor;
8989
import 'type_constraint_gatherer.dart' show TypeConstraintGatherer;
9090

9191
import 'type_inference_engine.dart'
92-
show IncludesTypeParametersCovariantly, TypeInferenceEngineImpl;
92+
show IncludesTypeParametersCovariantly, TypeInferenceEngine;
9393

9494
import 'type_promotion.dart' show TypePromoter, TypePromoterDisabled;
9595

@@ -395,7 +395,7 @@ abstract class TypeInferrerImpl extends TypeInferrer {
395395
static final FunctionType unknownFunction =
396396
new FunctionType(const [], const DynamicType());
397397

398-
final TypeInferenceEngineImpl engine;
398+
final TypeInferenceEngine engine;
399399

400400
@override
401401
final Uri uri;

0 commit comments

Comments
 (0)