Skip to content

Commit a6b1129

Browse files
johnniwintherCommit Queue
authored andcommitted
[cfe] Remove Builder.origin and Builder.isAugmenting
Augmentations no longer have the own Builder objects so the origin and isAugmenting properties can be removed from Builder. Lookup functions have been cleaned up accordingly. Change-Id: Ib872d88d400906ef3ada5f7ec7cb2fb81f8ef4ac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416961 Reviewed-by: Jens Johansen <[email protected]>
1 parent c326065 commit a6b1129

40 files changed

+217
-1028
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ class Import {
9292
};
9393
}
9494
NameIterator<Builder> iterator = importedLibraryBuilder!.exportNameSpace
95-
.filteredNameIterator(
96-
includeDuplicates: false, includeAugmentations: false);
95+
.filteredNameIterator(includeDuplicates: false);
9796
while (iterator.moveNext()) {
9897
String name = iterator.name;
9998
Builder member = iterator.current;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
12481248
Set<Uri> seenUris = new Set<Uri>();
12491249
for (DillLibraryBuilder builder in reusedResult.notReusedLibraries) {
12501250
if (builder.isPart) continue;
1251-
if (builder.isAugmenting) continue;
12521251
if (rebuildBodies!.contains(builder)) continue;
12531252
if (!seenUris.add(builder.importUri)) continue;
12541253
reusedResult.reusedLibraries.add(builder);
@@ -2213,9 +2212,6 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
22132212
// builder can exist multiple times in the values list.
22142213
for (DillLibraryBuilder builder in builders.values) {
22152214
if (builder.isPart) continue;
2216-
// TODO(jensj/ahe): This line can probably go away once
2217-
// https://dart-review.googlesource.com/47442 lands.
2218-
if (builder.isAugmenting) continue;
22192215
if (!seenUris.add(builder.importUri)) continue;
22202216
reusedLibraries.add(builder);
22212217
}

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

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,22 @@ abstract class NameSpace {
4343
/// Only members of type [T] are included. If [parent] is provided, on members
4444
/// declared in [parent] are included. If [includeDuplicates] is `true`, all
4545
/// duplicates of the same name are included, otherwise, only the first
46-
/// declared member is included. If [includeAugmentations] is `true`, both
47-
/// original and augmenting/patching members are included, otherwise, only
48-
/// original members are included.
46+
/// declared member is included.
4947
Iterator<T> filteredIterator<T extends Builder>(
50-
{Builder? parent,
51-
required bool includeDuplicates,
52-
required bool includeAugmentations});
48+
{required bool includeDuplicates});
5349

5450
/// Returns a filtered iterator of members and setters mapped in this name
5551
/// space.
5652
///
5753
/// Only members of type [T] are included. If [parent] is provided, on members
5854
/// declared in [parent] are included. If [includeDuplicates] is `true`, all
5955
/// duplicates of the same name are included, otherwise, only the first
60-
/// declared member is included. If [includeAugmentations] is `true`, both
61-
/// original and augmenting/patching members are included, otherwise, only
62-
/// original members are included.
56+
/// declared member is included.
6357
///
6458
/// Compared to [filteredIterator] this iterator also gives access to the
6559
/// name that the builders are mapped to.
6660
NameIterator<T> filteredNameIterator<T extends Builder>(
67-
{Builder? parent,
68-
required bool includeDuplicates,
69-
required bool includeAugmentations});
61+
{required bool includeDuplicates});
7062
}
7163

7264
abstract class DeclarationNameSpace implements NameSpace {
@@ -92,29 +84,21 @@ abstract class DeclarationNameSpace implements NameSpace {
9284
/// Only members of type [T] are included. If [parent] is provided, on members
9385
/// declared in [parent] are included. If [includeDuplicates] is `true`, all
9486
/// duplicates of the same name are included, otherwise, only the first
95-
/// declared member is included. If [includeAugmentations] is `true`, both
96-
/// original and augmenting/patching members are included, otherwise, only
97-
/// original members are included.
87+
/// declared member is included.
9888
Iterator<T> filteredConstructorIterator<T extends MemberBuilder>(
99-
{Builder? parent,
100-
required bool includeDuplicates,
101-
required bool includeAugmentations});
89+
{required bool includeDuplicates});
10290

10391
/// Returns a filtered iterator of constructors mapped in this scope.
10492
///
10593
/// Only members of type [T] are included. If [parent] is provided, on members
10694
/// declared in [parent] are included. If [includeDuplicates] is `true`, all
10795
/// duplicates of the same name are included, otherwise, only the first
108-
/// declared member is included. If [includeAugmentations] is `true`, both
109-
/// original and augmenting/patching members are included, otherwise, only
110-
/// original members are included.
96+
/// declared member is included.
11197
///
11298
/// Compared to [filteredConstructorIterator] this iterator also gives access
11399
/// to the name that the builders are mapped to.
114100
NameIterator<T> filteredConstructorNameIterator<T extends MemberBuilder>(
115-
{Builder? parent,
116-
required bool includeDuplicates,
117-
required bool includeAugmentations});
101+
{required bool includeDuplicates});
118102
}
119103

120104
class NameSpaceImpl implements NameSpace {
@@ -146,24 +130,16 @@ class NameSpaceImpl implements NameSpace {
146130

147131
@override
148132
Iterator<T> filteredIterator<T extends Builder>(
149-
{Builder? parent,
150-
required bool includeDuplicates,
151-
required bool includeAugmentations}) {
133+
{required bool includeDuplicates}) {
152134
return new FilteredIterator<T>(unfilteredIterator,
153-
parent: parent,
154-
includeDuplicates: includeDuplicates,
155-
includeAugmentations: includeAugmentations);
135+
includeDuplicates: includeDuplicates);
156136
}
157137

158138
@override
159139
NameIterator<T> filteredNameIterator<T extends Builder>(
160-
{Builder? parent,
161-
required bool includeDuplicates,
162-
required bool includeAugmentations}) {
140+
{required bool includeDuplicates}) {
163141
return new FilteredNameIterator<T>(unfilteredNameIterator,
164-
parent: parent,
165-
includeDuplicates: includeDuplicates,
166-
includeAugmentations: includeAugmentations);
142+
includeDuplicates: includeDuplicates);
167143
}
168144

169145
@override
@@ -243,24 +219,16 @@ class DeclarationNameSpaceImpl extends NameSpaceImpl
243219

244220
@override
245221
Iterator<T> filteredConstructorIterator<T extends MemberBuilder>(
246-
{Builder? parent,
247-
required bool includeDuplicates,
248-
required bool includeAugmentations}) {
222+
{required bool includeDuplicates}) {
249223
return new FilteredIterator<T>(unfilteredConstructorIterator,
250-
parent: parent,
251-
includeDuplicates: includeDuplicates,
252-
includeAugmentations: includeAugmentations);
224+
includeDuplicates: includeDuplicates);
253225
}
254226

255227
@override
256228
NameIterator<T> filteredConstructorNameIterator<T extends MemberBuilder>(
257-
{Builder? parent,
258-
required bool includeDuplicates,
259-
required bool includeAugmentations}) {
229+
{required bool includeDuplicates}) {
260230
return new FilteredNameIterator<T>(unfilteredConstructorNameIterator,
261-
parent: parent,
262-
includeDuplicates: includeDuplicates,
263-
includeAugmentations: includeAugmentations);
231+
includeDuplicates: includeDuplicates);
264232
}
265233

266234
@override

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,8 @@ class CompilationUnitPrefixScope extends BaseNameSpaceLookupScope {
556556
void forEachExtension(void Function(ExtensionBuilder) f) {
557557
if (_extensions == null) {
558558
Set<ExtensionBuilder> extensions = _extensions = {};
559-
Iterator<PrefixBuilder> iterator = _nameSpace.filteredIterator(
560-
includeDuplicates: false, includeAugmentations: false);
559+
Iterator<PrefixBuilder> iterator =
560+
_nameSpace.filteredIterator(includeDuplicates: false);
561561
while (iterator.moveNext()) {
562562
iterator.current.forEachExtension((e) {
563563
extensions.add(e);
@@ -1114,22 +1114,15 @@ class ConstructorNameSpaceNameIterator extends ConstructorNameSpaceIterator
11141114
/// Filtered builder [Iterator].
11151115
class FilteredIterator<T extends Builder> implements Iterator<T> {
11161116
final Iterator<Builder> _iterator;
1117-
final Builder? parent;
11181117
final bool includeDuplicates;
1119-
final bool includeAugmentations;
11201118

1121-
FilteredIterator(this._iterator,
1122-
{required this.parent,
1123-
required this.includeDuplicates,
1124-
required this.includeAugmentations});
1119+
FilteredIterator(this._iterator, {required this.includeDuplicates});
11251120

11261121
bool _include(Builder element) {
1127-
if (parent != null && element.parent != parent) return false;
11281122
if (!includeDuplicates &&
11291123
(element.isDuplicate || element.isConflictingAugmentationMember)) {
11301124
return false;
11311125
}
1132-
if (!includeAugmentations && element.isAugmenting) return false;
11331126
return element is T;
11341127
}
11351128

@@ -1154,22 +1147,15 @@ class FilteredIterator<T extends Builder> implements Iterator<T> {
11541147
/// access to the name that the builders are mapped to.
11551148
class FilteredNameIterator<T extends Builder> implements NameIterator<T> {
11561149
final NameIterator<Builder> _iterator;
1157-
final Builder? parent;
11581150
final bool includeDuplicates;
1159-
final bool includeAugmentations;
11601151

1161-
FilteredNameIterator(this._iterator,
1162-
{required this.parent,
1163-
required this.includeDuplicates,
1164-
required this.includeAugmentations});
1152+
FilteredNameIterator(this._iterator, {required this.includeDuplicates});
11651153

11661154
bool _include(Builder element) {
1167-
if (parent != null && element.parent != parent) return false;
11681155
if (!includeDuplicates &&
11691156
(element.isDuplicate || element.isConflictingAugmentationMember)) {
11701157
return false;
11711158
}
1172-
if (!includeAugmentations && element.isAugmenting) return false;
11731159
return element is T;
11741160
}
11751161

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ abstract class Builder {
1616

1717
int get fileOffset;
1818

19-
Builder get origin;
20-
2119
String get fullNameForErrors;
2220

2321
bool get hasProblem;
@@ -218,17 +216,6 @@ abstract class Builder {
218216

219217
bool get isLocal;
220218

221-
/// Returns `true` if this builder is augmenting another builder.
222-
///
223-
/// If `true`, the augmented builder is found through [origin] which is
224-
/// a different builder than this builder.
225-
///
226-
/// A class/member builder can be augmented through 'augment' modifier in
227-
/// augmentation libraries or through the `@patch` annotation in patch
228-
/// libraries. A library builder can be augmented through the augmentation
229-
/// libraries feature or through patch libraries.
230-
bool get isAugmenting;
231-
232219
/// Returns `true` if the related declaration is marked `augment`
233220
bool get isAugment;
234221

@@ -266,9 +253,6 @@ abstract class BuilderImpl implements Builder {
266253

267254
BuilderImpl();
268255

269-
@override
270-
Builder get origin => this;
271-
272256
@override
273257
bool get hasProblem => false;
274258

@@ -322,9 +306,6 @@ abstract class BuilderImpl implements Builder {
322306
@override
323307
bool get isLocal => false;
324308

325-
@override
326-
bool get isAugmenting => false;
327-
328309
@override
329310
bool get isAugment => false;
330311

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ mixin DeclarationBuilderMixin implements IDeclarationBuilder {
2323
Builder? findStaticBuilder(
2424
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
2525
{bool isSetter = false}) {
26-
if (accessingLibrary.nameOriginBuilder.origin !=
27-
libraryBuilder.nameOriginBuilder.origin &&
26+
if (accessingLibrary.nameOriginBuilder !=
27+
libraryBuilder.nameOriginBuilder &&
2828
name.startsWith("_")) {
2929
return null;
3030
}
@@ -68,10 +68,7 @@ mixin DeclarationBuilderMixin implements IDeclarationBuilder {
6868
}
6969

7070
void forEach(void f(String name, Builder builder)) {
71-
nameSpace
72-
.filteredNameIterator(
73-
includeDuplicates: false, includeAugmentations: false)
74-
.forEach(f);
71+
nameSpace.filteredNameIterator(includeDuplicates: false).forEach(f);
7572
}
7673

7774
@override

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

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ abstract class ClassBuilder implements DeclarationBuilder, ClassMemberAccess {
133133
/// Reference for the class built by this builder.
134134
Reference get reference;
135135

136-
@override
137-
ClassBuilder get origin;
138-
139136
abstract bool isNullClass;
140137

141138
@override
@@ -187,8 +184,8 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
187184
Builder? findStaticBuilder(
188185
String name, int fileOffset, Uri fileUri, LibraryBuilder accessingLibrary,
189186
{bool isSetter = false}) {
190-
if (accessingLibrary.nameOriginBuilder.origin !=
191-
libraryBuilder.nameOriginBuilder.origin &&
187+
if (accessingLibrary.nameOriginBuilder !=
188+
libraryBuilder.nameOriginBuilder &&
192189
name.startsWith("_")) {
193190
return null;
194191
}
@@ -206,23 +203,13 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
206203
isSetter: isSetter,
207204
forStaticAccess: true);
208205
}
209-
if (declaration == null && isAugmenting) {
210-
// Coverage-ignore-block(suite): Not run.
211-
return origin.findStaticBuilder(
212-
name, fileOffset, fileUri, accessingLibrary,
213-
isSetter: isSetter);
214-
}
215206
return declaration;
216207
}
217208

218209
@override
219210
Builder? lookupLocalMember(String name,
220211
{bool setter = false, bool required = false}) {
221212
Builder? builder = nameSpace.lookupLocalMember(name, setter: setter);
222-
if (builder == null && isAugmenting) {
223-
// Coverage-ignore-block(suite): Not run.
224-
builder = origin.nameSpace.lookupLocalMember(name, setter: setter);
225-
}
226213
if (required && builder == null) {
227214
internalProblem(
228215
templateInternalProblemNotFoundIn.withArguments(
@@ -374,11 +361,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
374361
@override
375362
Supertype buildMixedInType(
376363
LibraryBuilder library, List<TypeBuilder>? arguments) {
377-
Class cls = isAugmenting
378-
?
379-
// Coverage-ignore(suite): Not run.
380-
origin.cls
381-
: this.cls;
382364
if (arguments != null) {
383365
List<DartType> typeArguments =
384366
buildAliasedTypeArguments(library, arguments, /* hierarchy = */ null);
@@ -405,26 +387,6 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
405387
Member? lookupInstanceMember(ClassHierarchy hierarchy, Name name,
406388
{bool isSetter = false, bool isSuper = false}) {
407389
Class? instanceClass = cls;
408-
if (isAugmenting) {
409-
// Coverage-ignore-block(suite): Not run.
410-
assert(identical(instanceClass, origin.cls),
411-
"Found ${origin.cls} expected $instanceClass");
412-
if (isSuper) {
413-
// The super class is only correctly found through the origin class.
414-
instanceClass = origin.cls;
415-
} else {
416-
Member? member =
417-
hierarchy.getInterfaceMember(instanceClass, name, setter: isSetter);
418-
if (member?.parent == instanceClass) {
419-
// Only if the member is found in the augmentation can we use it.
420-
return member;
421-
} else {
422-
// Otherwise, we need to keep searching in the origin class.
423-
instanceClass = origin.cls;
424-
}
425-
}
426-
}
427-
428390
if (isSuper) {
429391
instanceClass = instanceClass.superclass;
430392
if (instanceClass == null) return null;

0 commit comments

Comments
 (0)