@@ -39,18 +39,15 @@ import '../modifier.dart';
3939import '../names.dart' show noSuchMethodName;
4040import '../problems.dart' show internalProblem, unhandled;
4141import '../scope.dart' ;
42- import '../source/source_constructor_builder.dart' ;
4342import '../source/source_factory_builder.dart' ;
4443import '../source/source_library_builder.dart' show SourceLibraryBuilder;
4544import '../source/source_loader.dart' ;
4645import '../source/source_member_builder.dart' ;
4746import '../type_inference/type_schema.dart' show UnknownType;
4847import '../util/helpers.dart' show DelayedActionPerformer;
4948import 'builder.dart' ;
50- import 'constructor_builder.dart' ;
5149import 'constructor_reference_builder.dart' ;
5250import 'declaration_builder.dart' ;
53- import 'field_builder.dart' ;
5451import 'function_builder.dart' ;
5552import 'library_builder.dart' ;
5653import 'member_builder.dart' ;
@@ -89,8 +86,6 @@ abstract class ClassBuilder implements DeclarationBuilder {
8986 @override
9087 Uri get fileUri;
9188
92- ClassBuilder ? get patchForTesting;
93-
9489 bool get isAbstract;
9590
9691 bool get isMacro;
@@ -120,13 +115,6 @@ abstract class ClassBuilder implements DeclarationBuilder {
120115
121116 void forEach (void f (String name, Builder builder));
122117
123- void forEachDeclaredField (
124- void Function (String name, FieldBuilder fieldBuilder) f);
125-
126- void forEachDeclaredConstructor (
127- void Function (String name, ConstructorBuilder constructorBuilder)
128- callback);
129-
130118 /// The [Class] built by this builder.
131119 ///
132120 /// For a patch class the origin class is returned.
@@ -258,17 +246,13 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
258246 @override
259247 ClassBuilder ? actualOrigin;
260248
261- @override
262- ClassBuilder ? get patchForTesting => _patchBuilder;
263-
264249 @override
265250 bool isNullClass = false ;
266251
267252 InterfaceType ? _legacyRawType;
268253 InterfaceType ? _nullableRawType;
269254 InterfaceType ? _nonNullableRawType;
270255 InterfaceType ? _thisType;
271- ClassBuilder ? _patchBuilder;
272256
273257 ClassBuilderImpl (
274258 List <MetadataBuilder >? metadata,
@@ -319,14 +303,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
319303 includeInjectedConstructors: includeInjectedConstructors);
320304 } else {
321305 constructors.forEach (f);
322- if (includeInjectedConstructors) {
323- _patchBuilder? .constructors
324- .forEach ((String name, MemberBuilder builder) {
325- if (! builder.isPatch) {
326- f (name, builder);
327- }
328- });
329- }
330306 }
331307 }
332308
@@ -415,57 +391,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
415391 scope.forEach (f);
416392 }
417393
418- @override
419- void forEachDeclaredField (
420- void Function (String name, FieldBuilder fieldBuilder) callback) {
421- void callbackFilteringFieldBuilders (String name, Builder builder) {
422- if (builder is FieldBuilder ) {
423- callback (name, builder);
424- }
425- }
426-
427- // Currently, fields can't be patched, but can be injected. When the fields
428- // will be made available for patching, the following code should iterate
429- // first over the fields from the patch and then -- over the fields in the
430- // original declaration, filtering out the patched fields. For now, the
431- // assert checks that the names of the fields from the original declaration
432- // and from the patch don't intersect.
433- assert (
434- _patchBuilder == null ||
435- _patchBuilder! .scope.localMembers
436- .where ((b) => b is FieldBuilder )
437- .map ((b) => (b as FieldBuilder ).name)
438- .toSet ()
439- .intersection (scope.localMembers
440- .where ((b) => b is FieldBuilder )
441- .map ((b) => (b as FieldBuilder ).name)
442- .toSet ())
443- .isEmpty,
444- "Detected an attempt to patch a field." );
445- _patchBuilder? .scope.forEach (callbackFilteringFieldBuilders);
446- scope.forEach (callbackFilteringFieldBuilders);
447- }
448-
449- @override
450- void forEachDeclaredConstructor (
451- void Function (
452- String name, DeclaredSourceConstructorBuilder constructorBuilder)
453- callback) {
454- Set <String > visitedConstructorNames = {};
455- void callbackFilteringFieldBuilders (String name, Builder builder) {
456- if (builder is DeclaredSourceConstructorBuilder &&
457- visitedConstructorNames.add (builder.name)) {
458- callback (name, builder);
459- }
460- }
461-
462- // Constructors can be patched, so iterate first over constructors in the
463- // patch, and then over constructors in the original declaration skipping
464- // those with the names that are in the patch.
465- _patchBuilder? .constructors.forEach (callbackFilteringFieldBuilders);
466- constructors.forEach (callbackFilteringFieldBuilders);
467- }
468-
469394 @override
470395 Builder ? lookupLocalMember (String name,
471396 {bool setter: false , bool required : false }) {
@@ -818,55 +743,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
818743 }
819744 }
820745
821- @override
822- void applyPatch (Builder patch) {
823- if (patch is ClassBuilder ) {
824- patch.actualOrigin = this ;
825- _patchBuilder = patch;
826- // TODO(ahe): Complain if `patch.supertype` isn't null.
827- scope.forEachLocalMember ((String name, Builder member) {
828- Builder ? memberPatch =
829- patch.scope.lookupLocalMember (name, setter: false );
830- if (memberPatch != null ) {
831- member.applyPatch (memberPatch);
832- }
833- });
834- scope.forEachLocalSetter ((String name, Builder member) {
835- Builder ? memberPatch =
836- patch.scope.lookupLocalMember (name, setter: true );
837- if (memberPatch != null ) {
838- member.applyPatch (memberPatch);
839- }
840- });
841- constructors.local.forEach ((String name, Builder member) {
842- Builder ? memberPatch = patch.constructors.local[name];
843- if (memberPatch != null ) {
844- member.applyPatch (memberPatch);
845- }
846- });
847-
848- int originLength = typeVariables? .length ?? 0 ;
849- int patchLength = patch.typeVariables? .length ?? 0 ;
850- if (originLength != patchLength) {
851- patch.addProblem (messagePatchClassTypeVariablesMismatch,
852- patch.charOffset, noLength, context: [
853- messagePatchClassOrigin.withLocation (fileUri, charOffset, noLength)
854- ]);
855- } else if (typeVariables != null ) {
856- int count = 0 ;
857- for (TypeVariableBuilder t in patch.typeVariables! ) {
858- typeVariables! [count++ ].applyPatch (t);
859- }
860- }
861- } else {
862- library.addProblem (messagePatchDeclarationMismatch, patch.charOffset,
863- noLength, patch.fileUri, context: [
864- messagePatchDeclarationOrigin.withLocation (
865- fileUri, charOffset, noLength)
866- ]);
867- }
868- }
869-
870746 @override
871747 FunctionType ? computeRedirecteeType (
872748 RedirectingFactoryBuilder factory , TypeEnvironment typeEnvironment) {
0 commit comments