Skip to content

Commit ac2a58a

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Remove MemberBuilder.member
Change-Id: I105354c102acaca321045bacc273165792a46aae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389701 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Chloe Stefantsova <[email protected]>
1 parent b72e453 commit ac2a58a

26 files changed

+216
-156
lines changed

pkg/front_end/lib/src/base/scope.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,6 @@ mixin ErroneousMemberBuilderMixin implements SourceMemberBuilder {
640640
// Coverage-ignore(suite): Not run.
641641
MemberDataForTesting? get dataForTesting => null;
642642

643-
@override
644-
// Coverage-ignore(suite): Not run.
645-
Member get member => throw new UnsupportedError('$runtimeType.member');
646-
647643
@override
648644
// Coverage-ignore(suite): Not run.
649645
Name get memberName => throw new UnsupportedError('$runtimeType.memberName');

pkg/front_end/lib/src/builder/member_builder.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,24 @@ abstract class MemberBuilder implements Builder {
2222
/// The declared name of this member;
2323
Name get memberName;
2424

25-
/// The [Member] built by this builder;
26-
Member get member;
27-
2825
/// The [Member] to use when reading from this member builder.
2926
///
30-
/// For a field, a getter or a regular method this is the [member] itself.
27+
/// For a field, a getter or a regular method this is the member itself.
3128
/// For an instance extension method this is special tear-off function. For
3229
/// a constructor, an operator, a factory or a setter this is `null`.
3330
Member? get readTarget;
3431

3532
/// The [Member] to use when write to this member builder.
3633
///
37-
/// For an assignable field or a setter this is the [member] itself. For
34+
/// For an assignable field or a setter this is the member itself. For
3835
/// a constructor, a non-assignable field, a getter, an operator or a regular
3936
/// method this is `null`.
4037
Member? get writeTarget;
4138

4239
/// The [Member] to use when invoking this member builder.
4340
///
4441
/// For a constructor, a field, a regular method, a getter, an operator or
45-
/// a factory this is the [member] itself. For a setter this is `null`.
42+
/// a factory this is the member itself. For a setter this is `null`.
4643
Member? get invokeTarget;
4744

4845
/// The members from this builder that are accessible in exports through
@@ -222,7 +219,7 @@ abstract class BuilderClassMember implements ClassMember {
222219
}
223220

224221
@override
225-
bool get isAbstract => memberBuilder.member.isAbstract;
222+
bool get isAbstract => memberBuilder.isAbstract;
226223

227224
@override
228225
bool get isSynthesized => false;

pkg/front_end/lib/src/dill/dill_extension_member_builder.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class DillExtensionFieldBuilder extends DillExtensionMemberBuilder {
5959
Member? get writeTarget => isAssignable ? field : null;
6060

6161
@override
62-
// Coverage-ignore(suite): Not run.
6362
Member get invokeTarget => field;
6463

6564
@override
@@ -124,6 +123,7 @@ class DillExtensionOperatorBuilder extends DillExtensionMemberBuilder {
124123
super(procedure, descriptor, parent);
125124

126125
@override
126+
// Coverage-ignore(suite): Not run.
127127
Member get member => procedure;
128128

129129
@override
@@ -158,7 +158,6 @@ class DillExtensionStaticMethodBuilder extends DillExtensionMemberBuilder {
158158
Member? get writeTarget => null;
159159

160160
@override
161-
// Coverage-ignore(suite): Not run.
162161
Member get invokeTarget => procedure;
163162
}
164163

pkg/front_end/lib/src/dill/dill_extension_type_member_builder.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class DillExtensionTypeFieldBuilder extends DillExtensionTypeMemberBuilder {
102102
Member? get writeTarget => isAssignable ? field : null;
103103

104104
@override
105-
// Coverage-ignore(suite): Not run.
106105
Member get invokeTarget => field;
107106

108107
@override
@@ -198,7 +197,6 @@ class DillExtensionTypeStaticMethodBuilder
198197
Member? get writeTarget => null;
199198

200199
@override
201-
// Coverage-ignore(suite): Not run.
202200
Member get invokeTarget => procedure;
203201
}
204202

@@ -251,6 +249,7 @@ class DillExtensionTypeConstructorBuilder extends DillExtensionTypeMemberBuilder
251249
FunctionNode get function => constructor.function;
252250

253251
@override
252+
// Coverage-ignore(suite): Not run.
254253
Procedure get member => constructor;
255254

256255
@override

pkg/front_end/lib/src/dill/dill_library_builder.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,10 @@ class DillLibraryBuilder extends LibraryBuilderImpl {
471471
(declaration is ClassBuilder && node == declaration.cls) ||
472472
(declaration is TypeAliasBuilder &&
473473
reference == declaration.reference) ||
474-
(declaration is MemberBuilder && node == declaration.member) ||
474+
(declaration is MemberBuilder &&
475+
(node == declaration.readTarget ||
476+
node == declaration.invokeTarget ||
477+
node == declaration.writeTarget)) ||
475478
(declaration is ExtensionBuilder &&
476479
reference == declaration.reference) ||
477480
(declaration is ExtensionTypeDeclarationBuilder &&

pkg/front_end/lib/src/dill/dill_member_builder.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ abstract class DillMemberBuilder extends MemberBuilderImpl {
2929
DillMemberBuilder(Member member, Builder parent)
3030
: super(parent, member.fileUri, member.fileOffset);
3131

32-
@override
3332
Member get member;
3433

3534
@override
@@ -127,7 +126,6 @@ class DillFieldBuilder extends DillMemberBuilder implements FieldBuilder {
127126
Member? get writeTarget => isAssignable ? field : null;
128127

129128
@override
130-
// Coverage-ignore(suite): Not run.
131129
Member? get invokeTarget => field;
132130

133131
@override
@@ -186,7 +184,6 @@ class DillGetterBuilder extends DillProcedureBuilder {
186184
Member? get writeTarget => null;
187185

188186
@override
189-
// Coverage-ignore(suite): Not run.
190187
Member get invokeTarget => procedure;
191188
}
192189

@@ -199,14 +196,12 @@ class DillSetterBuilder extends DillProcedureBuilder {
199196
Member get member => procedure;
200197

201198
@override
202-
// Coverage-ignore(suite): Not run.
203199
Member? get readTarget => null;
204200

205201
@override
206202
Member get writeTarget => procedure;
207203

208204
@override
209-
// Coverage-ignore(suite): Not run.
210205
Member? get invokeTarget => null;
211206
}
212207

@@ -222,11 +217,9 @@ class DillMethodBuilder extends DillProcedureBuilder {
222217
Member get readTarget => procedure;
223218

224219
@override
225-
// Coverage-ignore(suite): Not run.
226220
Member? get writeTarget => null;
227221

228222
@override
229-
// Coverage-ignore(suite): Not run.
230223
Member get invokeTarget => procedure;
231224
}
232225

pkg/front_end/lib/src/kernel/body_builder.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3313,7 +3313,12 @@ class BodyBuilder extends StackListenerImpl
33133313
assert(declaration.isStatic || declaration.isTopLevel);
33143314
MemberBuilder memberBuilder = declaration as MemberBuilder;
33153315
return new StaticAccessGenerator(
3316-
this, nameToken, name, memberBuilder.member, null);
3316+
this,
3317+
nameToken,
3318+
name,
3319+
memberBuilder.readTarget,
3320+
memberBuilder.invokeTarget,
3321+
memberBuilder.writeTarget);
33173322
} else if (declaration is PrefixBuilder) {
33183323
assert(prefix == null);
33193324
// Wildcard import prefixes are non-binding and cannot be used.
@@ -6515,9 +6520,9 @@ class BodyBuilder extends StackListenerImpl
65156520
typeDeclarationBuilder.name,
65166521
nameToken.charOffset));
65176522
}
6518-
target = constructorBuilder.member;
6523+
target = constructorBuilder.invokeTarget;
65196524
} else {
6520-
target = constructorBuilder.member;
6525+
target = constructorBuilder.invokeTarget;
65216526
}
65226527
if (target is Constructor ||
65236528
(target is Procedure &&
@@ -6760,9 +6765,9 @@ class BodyBuilder extends StackListenerImpl
67606765
typeDeclarationBuilder.name,
67616766
nameToken.charOffset));
67626767
}
6763-
target = constructorBuilder.member;
6768+
target = constructorBuilder.invokeTarget;
67646769
} else {
6765-
target = constructorBuilder.member;
6770+
target = constructorBuilder.invokeTarget;
67666771
}
67676772
if (typeDeclarationBuilder.isEnum &&
67686773
!(libraryFeatures.enhancedEnums.isEnabled &&
@@ -6796,7 +6801,7 @@ class BodyBuilder extends StackListenerImpl
67966801
message = constructorBuilder.message
67976802
.withLocation(uri, charOffset, noLength);
67986803
} else {
6799-
target = constructorBuilder.member;
6804+
target = constructorBuilder.invokeTarget;
68006805
}
68016806
if (target != null) {
68026807
return buildStaticInvocation(target, arguments,
@@ -9089,7 +9094,7 @@ class BodyBuilder extends StackListenerImpl
90899094
MemberBuilder constructor =
90909095
libraryBuilder.loader.getDuplicatedFieldInitializerError();
90919096
Expression invocation = buildStaticInvocation(
9092-
constructor.member,
9097+
constructor.invokeTarget!,
90939098
forest.createArguments(assignmentOffset, <Expression>[
90949099
forest.createStringLiteral(assignmentOffset, name)
90959100
]),

pkg/front_end/lib/src/kernel/body_builder_context.dart

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ mixin _MemberBodyBuilderContext<T extends SourceMemberBuilder>
624624
implements BodyBuilderContext {
625625
T get _member;
626626

627+
Member get _builtMember;
628+
627629
@override
628630
AugmentSuperTarget? get augmentSuperTarget {
629631
if (_member.isAugmentation) {
@@ -633,20 +635,23 @@ mixin _MemberBodyBuilderContext<T extends SourceMemberBuilder>
633635
}
634636

635637
@override
636-
void registerSuperCall() {
637-
_member.member.transformerFlags |= TransformerFlag.superCalls;
638-
}
638+
int get memberCharOffset => _member.charOffset;
639639

640640
@override
641-
int get memberCharOffset => _member.charOffset;
641+
void registerSuperCall() {
642+
_builtMember.transformerFlags |= TransformerFlag.superCalls;
643+
}
642644
}
643645

644646
class FieldBodyBuilderContext extends BodyBuilderContext
645647
with _MemberBodyBuilderContext<SourceFieldBuilder> {
646648
@override
647649
SourceFieldBuilder _member;
648650

649-
FieldBodyBuilderContext(this._member,
651+
@override
652+
final Member _builtMember;
653+
654+
FieldBodyBuilderContext(this._member, this._builtMember,
650655
{required bool inOutlineBuildingPhase,
651656
required bool inMetadata,
652657
required bool inConstFields})
@@ -780,7 +785,10 @@ class ProcedureBodyBuilderContext extends BodyBuilderContext
780785
@override
781786
final SourceProcedureBuilder _member;
782787

783-
ProcedureBodyBuilderContext(this._member,
788+
@override
789+
final Member _builtMember;
790+
791+
ProcedureBodyBuilderContext(this._member, this._builtMember,
784792
{required bool inOutlineBuildingPhase,
785793
required bool inMetadata,
786794
required bool inConstFields})
@@ -799,6 +807,8 @@ mixin _ConstructorBodyBuilderContextMixin<T extends ConstructorDeclaration>
799807
implements BodyBuilderContext {
800808
T get _member;
801809

810+
TreeNode get _initializerParent;
811+
802812
@override
803813
DartType substituteFieldType(DartType fieldType) {
804814
return _member.substituteFieldType(fieldType);
@@ -818,7 +828,7 @@ mixin _ConstructorBodyBuilderContextMixin<T extends ConstructorDeclaration>
818828
void addInitializer(Initializer initializer, ExpressionGeneratorHelper helper,
819829
{required InitializerInferenceResult? inferenceResult}) {
820830
_member.addInitializer(initializer, helper,
821-
inferenceResult: inferenceResult);
831+
inferenceResult: inferenceResult, parent: _initializerParent);
822832
}
823833

824834
@override
@@ -859,7 +869,10 @@ class ConstructorBodyBuilderContext extends BodyBuilderContext
859869
@override
860870
final DeclaredSourceConstructorBuilder _member;
861871

862-
ConstructorBodyBuilderContext(this._member,
872+
@override
873+
final Member _builtMember;
874+
875+
ConstructorBodyBuilderContext(this._member, this._builtMember,
863876
{required bool inOutlineBuildingPhase,
864877
required bool inMetadata,
865878
required bool inConstFields})
@@ -883,6 +896,9 @@ class ConstructorBodyBuilderContext extends BodyBuilderContext
883896
@override
884897
// Coverage-ignore(suite): Not run.
885898
bool get hasFormalParameters => true;
899+
900+
@override
901+
TreeNode get _initializerParent => _member.invokeTarget;
886902
}
887903

888904
class ExtensionTypeConstructorBodyBuilderContext extends BodyBuilderContext
@@ -893,8 +909,10 @@ class ExtensionTypeConstructorBodyBuilderContext extends BodyBuilderContext
893909
_MemberBodyBuilderContext<SourceExtensionTypeConstructorBuilder> {
894910
@override
895911
final SourceExtensionTypeConstructorBuilder _member;
912+
@override
913+
final Member _builtMember;
896914

897-
ExtensionTypeConstructorBodyBuilderContext(this._member,
915+
ExtensionTypeConstructorBodyBuilderContext(this._member, this._builtMember,
898916
{required bool inOutlineBuildingPhase,
899917
required bool inMetadata,
900918
required bool inConstFields})
@@ -912,6 +930,9 @@ class ExtensionTypeConstructorBodyBuilderContext extends BodyBuilderContext
912930
@override
913931
// Coverage-ignore(suite): Not run.
914932
bool get hasFormalParameters => true;
933+
934+
@override
935+
TreeNode get _initializerParent => _member.invokeTarget;
915936
}
916937

917938
class FactoryBodyBuilderContext extends BodyBuilderContext
@@ -921,7 +942,10 @@ class FactoryBodyBuilderContext extends BodyBuilderContext
921942
@override
922943
final SourceFactoryBuilder _member;
923944

924-
FactoryBodyBuilderContext(this._member,
945+
@override
946+
final Member _builtMember;
947+
948+
FactoryBodyBuilderContext(this._member, this._builtMember,
925949
{required bool inOutlineBuildingPhase,
926950
required bool inMetadata,
927951
required bool inConstFields})
@@ -953,7 +977,10 @@ class RedirectingFactoryBodyBuilderContext extends BodyBuilderContext
953977
@override
954978
final RedirectingFactoryBuilder _member;
955979

956-
RedirectingFactoryBodyBuilderContext(this._member,
980+
@override
981+
final Member _builtMember;
982+
983+
RedirectingFactoryBodyBuilderContext(this._member, this._builtMember,
957984
{required bool inOutlineBuildingPhase,
958985
required bool inMetadata,
959986
required bool inConstFields})
@@ -1016,8 +1043,11 @@ class ExpressionCompilerProcedureBodyBuildContext extends BodyBuilderContext
10161043
@override
10171044
final SourceProcedureBuilder _member;
10181045

1046+
@override
1047+
final Member _builtMember;
1048+
10191049
ExpressionCompilerProcedureBodyBuildContext(
1020-
DietListener listener, this._member,
1050+
DietListener listener, this._member, this._builtMember,
10211051
{required bool isDeclarationInstanceMember,
10221052
required bool inOutlineBuildingPhase,
10231053
required bool inMetadata,

0 commit comments

Comments
 (0)