@@ -126,8 +126,7 @@ void *ConformanceLookupTable::operator new(size_t Bytes,
126
126
return C.Allocate (Bytes, Alignment);
127
127
}
128
128
129
- ConformanceLookupTable::ConformanceLookupTable (ASTContext &ctx,
130
- LazyResolver *resolver) {
129
+ ConformanceLookupTable::ConformanceLookupTable (ASTContext &ctx) {
131
130
// Register a cleanup with the ASTContext to call the conformance
132
131
// table destructor.
133
132
ctx.addCleanup ([this ]() {
@@ -146,7 +145,6 @@ namespace {
146
145
template <typename NominalFunc, typename ExtensionFunc>
147
146
void ConformanceLookupTable::forEachInStage (ConformanceStage stage,
148
147
NominalTypeDecl *nominal,
149
- LazyResolver *resolver,
150
148
NominalFunc nominalFunc,
151
149
ExtensionFunc extensionFunc) {
152
150
assert (static_cast <unsigned >(stage) < NumConformanceStages &&
@@ -212,8 +210,7 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
212
210
213
211
void ConformanceLookupTable::inheritConformances (ClassDecl *classDecl,
214
212
ClassDecl *superclassDecl,
215
- ExtensionDecl *superclassExt,
216
- LazyResolver *resolver) {
213
+ ExtensionDecl *superclassExt) {
217
214
// Local function to return the location of the superclass. This
218
215
// takes a little digging, so compute on first use and cache it.
219
216
SourceLoc superclassLoc;
@@ -267,13 +264,12 @@ void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,
267
264
}
268
265
269
266
void ConformanceLookupTable::updateLookupTable (NominalTypeDecl *nominal,
270
- ConformanceStage stage,
271
- LazyResolver *resolver) {
267
+ ConformanceStage stage) {
272
268
switch (stage) {
273
269
case ConformanceStage::RecordedExplicit:
274
270
// Record all of the explicit conformances.
275
271
forEachInStage (
276
- stage, nominal, resolver,
272
+ stage, nominal,
277
273
[&](NominalTypeDecl *nominal) {
278
274
addInheritedProtocols (nominal,
279
275
ConformanceSource::forExplicit (nominal));
@@ -289,7 +285,7 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
289
285
break ;
290
286
291
287
case ConformanceStage::Inherited:
292
- updateLookupTable (nominal, ConformanceStage::RecordedExplicit, resolver );
288
+ updateLookupTable (nominal, ConformanceStage::RecordedExplicit);
293
289
294
290
// For classes, expand implied conformances of the superclass,
295
291
// because an implied conformance in the superclass is considered
@@ -310,8 +306,7 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
310
306
superclassDecl->prepareConformanceTable ();
311
307
superclassDecl->ConformanceTable ->updateLookupTable (
312
308
superclassDecl,
313
- ConformanceStage::Resolved,
314
- resolver);
309
+ ConformanceStage::Resolved);
315
310
316
311
// Expand inherited conformances from all superclasses.
317
312
// We may have circular inheritance in ill-formed classes, so keep an
@@ -320,15 +315,14 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
320
315
321
316
do {
322
317
forEachInStage (
323
- stage, superclassDecl, resolver,
318
+ stage, superclassDecl,
324
319
[&](NominalTypeDecl *superclass) {
325
- inheritConformances (classDecl, superclassDecl, nullptr ,
326
- resolver);
320
+ inheritConformances (classDecl, superclassDecl, nullptr );
327
321
},
328
322
[&](ExtensionDecl *ext,
329
323
ArrayRef<ConformanceConstructionInfo> protos) {
330
324
(void )protos;
331
- inheritConformances (classDecl, superclassDecl, ext, resolver );
325
+ inheritConformances (classDecl, superclassDecl, ext);
332
326
});
333
327
superclassDecl = superclassDecl->getSuperclassDecl ();
334
328
if (circularSuperclass)
@@ -343,30 +337,30 @@ void ConformanceLookupTable::updateLookupTable(NominalTypeDecl *nominal,
343
337
case ConformanceStage::ExpandedImplied:
344
338
// Record explicit conformances and import inherited conformances
345
339
// before expanding.
346
- updateLookupTable (nominal, ConformanceStage::Inherited, resolver );
340
+ updateLookupTable (nominal, ConformanceStage::Inherited);
347
341
348
342
// Expand inherited conformances.
349
343
forEachInStage (
350
- stage, nominal, resolver,
344
+ stage, nominal,
351
345
[&](NominalTypeDecl *nominal) {
352
- expandImpliedConformances (nominal, nominal, resolver );
346
+ expandImpliedConformances (nominal, nominal);
353
347
},
354
348
[&](ExtensionDecl *ext,
355
349
ArrayRef<ConformanceConstructionInfo> protos) {
356
350
(void )protos;
357
- expandImpliedConformances (nominal, ext, resolver );
351
+ expandImpliedConformances (nominal, ext);
358
352
});
359
353
break ;
360
354
361
355
case ConformanceStage::Resolved:
362
356
// Expand inherited conformances so we have the complete set of
363
357
// conformances.
364
- updateLookupTable (nominal, ConformanceStage::ExpandedImplied, resolver );
358
+ updateLookupTable (nominal, ConformanceStage::ExpandedImplied);
365
359
366
360
// / Determine whether any extensions were added that might require
367
361
// / us to compute conformances again.
368
362
bool anyChanged = false ;
369
- forEachInStage (stage, nominal, resolver,
363
+ forEachInStage (stage, nominal,
370
364
[&](NominalTypeDecl *nominal) { anyChanged = true ; },
371
365
[&](ExtensionDecl *ext,
372
366
ArrayRef<ConformanceConstructionInfo>) {
@@ -481,8 +475,7 @@ void ConformanceLookupTable::addInheritedProtocols(
481
475
}
482
476
483
477
void ConformanceLookupTable::expandImpliedConformances (NominalTypeDecl *nominal,
484
- DeclContext *dc,
485
- LazyResolver *resolver) {
478
+ DeclContext *dc) {
486
479
// Note: recursive type-checking implies that AllConformances
487
480
// may be reallocated during this traversal, so pay the lookup cost
488
481
// during each iteration.
@@ -941,16 +934,15 @@ bool ConformanceLookupTable::lookupConformance(
941
934
ModuleDecl *module ,
942
935
NominalTypeDecl *nominal,
943
936
ProtocolDecl *protocol,
944
- LazyResolver *resolver,
945
937
SmallVectorImpl<ProtocolConformance *> &conformances) {
946
938
// Update to record all explicit and inherited conformances.
947
- updateLookupTable (nominal, ConformanceStage::Inherited, resolver );
939
+ updateLookupTable (nominal, ConformanceStage::Inherited);
948
940
949
941
// Look for conformances to this protocol.
950
942
auto known = Conformances.find (protocol);
951
943
if (known == Conformances.end ()) {
952
944
// If we didn't find anything, expand implied conformances.
953
- updateLookupTable (nominal, ConformanceStage::ExpandedImplied, resolver );
945
+ updateLookupTable (nominal, ConformanceStage::ExpandedImplied);
954
946
known = Conformances.find (protocol);
955
947
956
948
// We didn't find anything.
@@ -971,14 +963,13 @@ bool ConformanceLookupTable::lookupConformance(
971
963
void ConformanceLookupTable::lookupConformances (
972
964
NominalTypeDecl *nominal,
973
965
DeclContext *dc,
974
- LazyResolver *resolver,
975
966
ConformanceLookupKind lookupKind,
976
967
SmallVectorImpl<ProtocolDecl *> *protocols,
977
968
SmallVectorImpl<ProtocolConformance *> *conformances,
978
969
SmallVectorImpl<ConformanceDiagnostic> *diagnostics) {
979
970
// We need to expand all implied conformances before we can find
980
971
// those conformances that pertain to this declaration context.
981
- updateLookupTable (nominal, ConformanceStage::ExpandedImplied, resolver );
972
+ updateLookupTable (nominal, ConformanceStage::ExpandedImplied);
982
973
983
974
// / Resolve conformances for each of the protocols to which this
984
975
// / declaration may provide a conformance. Only some of these will
@@ -1041,11 +1032,10 @@ void ConformanceLookupTable::lookupConformances(
1041
1032
1042
1033
void ConformanceLookupTable::getAllProtocols (
1043
1034
NominalTypeDecl *nominal,
1044
- LazyResolver *resolver,
1045
1035
SmallVectorImpl<ProtocolDecl *> &scratch) {
1046
1036
// We need to expand all implied conformances to find the complete
1047
1037
// set of protocols to which this nominal type conforms.
1048
- updateLookupTable (nominal, ConformanceStage::ExpandedImplied, resolver );
1038
+ updateLookupTable (nominal, ConformanceStage::ExpandedImplied);
1049
1039
1050
1040
// Gather all of the protocols.
1051
1041
for (const auto &conformance : Conformances) {
@@ -1096,11 +1086,10 @@ int ConformanceLookupTable::compareProtocolConformances(
1096
1086
1097
1087
void ConformanceLookupTable::getAllConformances (
1098
1088
NominalTypeDecl *nominal,
1099
- LazyResolver *resolver,
1100
1089
bool sorted,
1101
1090
SmallVectorImpl<ProtocolConformance *> &scratch) {
1102
1091
// We need to expand and resolve all conformances to enumerate them.
1103
- updateLookupTable (nominal, ConformanceStage::Resolved, resolver );
1092
+ updateLookupTable (nominal, ConformanceStage::Resolved);
1104
1093
1105
1094
// Gather all of the protocols.
1106
1095
for (const auto &conformance : AllConformances) {
@@ -1131,24 +1120,23 @@ ArrayRef<ValueDecl *>
1131
1120
ConformanceLookupTable::getSatisfiedProtocolRequirementsForMember (
1132
1121
const ValueDecl *member,
1133
1122
NominalTypeDecl *nominal,
1134
- LazyResolver *resolver,
1135
1123
bool sorted) {
1136
1124
auto It = ConformingDeclMap.find (member);
1137
1125
if (It != ConformingDeclMap.end ())
1138
1126
return It->second ;
1139
1127
1140
1128
SmallVector<ProtocolConformance *, 4 > result;
1141
- getAllConformances (nominal, resolver, sorted, result);
1129
+ getAllConformances (nominal, sorted, result);
1142
1130
1143
1131
auto &reqs = ConformingDeclMap[member];
1144
1132
if (isa<TypeDecl>(member)) {
1145
1133
for (auto *conf : result) {
1146
1134
if (conf->isInvalid ())
1147
1135
continue ;
1148
1136
1149
- conf->forEachTypeWitness (resolver , [&](const AssociatedTypeDecl *assoc,
1150
- Type type,
1151
- TypeDecl *typeDecl) -> bool {
1137
+ conf->forEachTypeWitness (nullptr , [&](const AssociatedTypeDecl *assoc,
1138
+ Type type,
1139
+ TypeDecl *typeDecl) -> bool {
1152
1140
if (typeDecl == member)
1153
1141
reqs.push_back (const_cast <AssociatedTypeDecl*>(assoc));
1154
1142
return false ;
@@ -1160,8 +1148,8 @@ ConformanceLookupTable::getSatisfiedProtocolRequirementsForMember(
1160
1148
continue ;
1161
1149
1162
1150
auto normal = conf->getRootNormalConformance ();
1163
- normal->forEachValueWitness (resolver, [&](ValueDecl *req ,
1164
- Witness witness) {
1151
+ normal->forEachValueWitness (nullptr ,
1152
+ [&](ValueDecl *req, Witness witness) {
1165
1153
if (witness.getDecl () == member)
1166
1154
reqs.push_back (req);
1167
1155
});
0 commit comments