@@ -8,27 +8,18 @@ import 'package:kernel/class_hierarchy.dart';
88import 'package:kernel/src/assumptions.dart' ;
99import 'package:kernel/src/printer.dart' ;
1010
11- import '../base/constant_context.dart' ;
1211import '../base/problems.dart' show unsupported;
1312import '../builder/inferable_type_builder.dart' ;
1413import '../builder/type_builder.dart' ;
1514import '../codes/cfe_codes.dart' ;
16- import '../source/source_field_builder.dart' ;
1715import '../source/source_library_builder.dart' ;
18- import '../type_inference/type_inferrer.dart' ;
19- import 'body_builder.dart' ;
20- import 'body_builder_context.dart' ;
2116
2217abstract class InferredType extends AuxiliaryType {
2318 Uri ? get fileUri;
2419 int ? get charOffset;
2520
2621 InferredType ._();
2722
28- factory InferredType .fromFieldInitializer (
29- SourceFieldBuilder fieldBuilder, Token ? initializerToken) =
30- _ImplicitFieldTypeRoot ;
31-
3223 factory InferredType (
3324 {required SourceLibraryBuilder libraryBuilder,
3425 required TypeBuilder typeBuilder,
@@ -101,100 +92,6 @@ abstract class InferredType extends AuxiliaryType {
10192 DartType computeType (ClassHierarchyBase hierarchy);
10293}
10394
104- // Coverage-ignore(suite): Not run.
105- class _ImplicitFieldTypeRoot extends InferredType {
106- final SourceFieldBuilder fieldBuilder;
107-
108- Token ? initializerToken;
109- bool isStarted = false ;
110-
111- _ImplicitFieldTypeRoot (this .fieldBuilder, this .initializerToken) : super ._();
112-
113- @override
114- Uri get fileUri => fieldBuilder.fileUri;
115-
116- @override
117- int get charOffset => fieldBuilder.fileOffset;
118-
119- @override
120- DartType inferType (ClassHierarchyBase hierarchy) {
121- return fieldBuilder.inferType (hierarchy);
122- }
123-
124- @override
125- DartType computeType (ClassHierarchyBase hierarchy) {
126- if (isStarted) {
127- fieldBuilder.libraryBuilder.addProblem (
128- templateCantInferTypeDueToCircularity
129- .withArguments (fieldBuilder.name),
130- fieldBuilder.fileOffset,
131- fieldBuilder.name.length,
132- fieldBuilder.fileUri);
133- DartType type = const InvalidType ();
134- fieldBuilder.type.registerInferredType (type);
135- return type;
136- }
137- isStarted = true ;
138- DartType ? inferredType;
139- if (initializerToken != null ) {
140- InterfaceType ? enclosingClassThisType = fieldBuilder.classBuilder == null
141- ? null
142- : fieldBuilder.libraryBuilder.loader.typeInferenceEngine.coreTypes
143- .thisInterfaceType (fieldBuilder.classBuilder! .cls,
144- fieldBuilder.libraryBuilder.library.nonNullable);
145- TypeInferrer typeInferrer = fieldBuilder
146- .libraryBuilder.loader.typeInferenceEngine
147- .createTopLevelTypeInferrer (
148- fieldBuilder.fileUri,
149- enclosingClassThisType,
150- fieldBuilder.libraryBuilder,
151- fieldBuilder.dataForTesting? .inferenceData);
152- BodyBuilderContext bodyBuilderContext =
153- fieldBuilder.createBodyBuilderContext ();
154- BodyBuilder bodyBuilder = fieldBuilder.libraryBuilder.loader
155- .createBodyBuilderForField (
156- fieldBuilder.libraryBuilder,
157- bodyBuilderContext,
158- fieldBuilder.declarationBuilder? .scope ??
159- fieldBuilder.libraryBuilder.scope,
160- typeInferrer,
161- fieldBuilder.fileUri);
162- bodyBuilder.constantContext = fieldBuilder.isConst
163- ? ConstantContext .inferred
164- : ConstantContext .none;
165- bodyBuilder.inFieldInitializer = true ;
166- bodyBuilder.inLateFieldInitializer = fieldBuilder.isLate;
167- Expression initializer =
168- bodyBuilder.parseFieldInitializer (initializerToken! );
169- initializerToken = null ;
170-
171- inferredType =
172- typeInferrer.inferImplicitFieldType (bodyBuilder, initializer);
173- } else {
174- inferredType = const DynamicType ();
175- }
176- return inferredType;
177- }
178-
179- @override
180- void toTextInternal (AstPrinter printer) {
181- printer.write ('<implicit-field-type:$fieldBuilder >' );
182- }
183-
184- @override
185- bool equals (Object other, Assumptions ? assumptions) {
186- if (identical (this , other)) return true ;
187- return other is _ImplicitFieldTypeRoot &&
188- fieldBuilder == other.fieldBuilder;
189- }
190-
191- @override
192- int get hashCode => fieldBuilder.hashCode;
193-
194- @override
195- String toString () => 'ImplicitFieldType(${toStringInternal ()})' ;
196- }
197-
19895/// Signature for function called to trigger the inference of the type of
19996/// [_ImplicitType] , if it hasn't already been computed.
20097typedef InferTypeFunction = DartType Function (ClassHierarchyBase hierarchy);
0 commit comments