@@ -148,19 +148,16 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
148
148
149
149
// / Return true if the conformance has a witness for the given associated
150
150
// / type.
151
- bool hasTypeWitness (AssociatedTypeDecl *assocType,
152
- LazyResolver *resolver = nullptr ) const ;
151
+ bool hasTypeWitness (AssociatedTypeDecl *assocType) const ;
153
152
154
153
// / Retrieve the type witness for the given associated type.
155
154
Type getTypeWitness (AssociatedTypeDecl *assocType,
156
- LazyResolver *resolver,
157
155
SubstOptions options = None) const ;
158
156
159
157
// / Retrieve the type witness and type decl (if one exists)
160
158
// / for the given associated type.
161
159
std::pair<Type, TypeDecl *>
162
160
getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
163
- LazyResolver *resolver,
164
161
SubstOptions options = None) const ;
165
162
166
163
// / Apply the given function object to each type witness within this
@@ -173,17 +170,17 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
173
170
// /
174
171
// / \returns true if the function ever returned true
175
172
template <typename F>
176
- bool forEachTypeWitness (LazyResolver *resolver, F f ) const {
173
+ bool forEachTypeWitness (F f, bool useResolver= false ) const {
177
174
const ProtocolDecl *protocol = getProtocol ();
178
175
for (auto assocTypeReq : protocol->getAssociatedTypeMembers ()) {
179
176
if (assocTypeReq->isInvalid ())
180
177
continue ;
181
178
182
179
// If we don't have and cannot resolve witnesses, skip it.
183
- if (!resolver && !hasTypeWitness (assocTypeReq))
180
+ if (!useResolver && !hasTypeWitness (assocTypeReq))
184
181
continue ;
185
182
186
- const auto &TWInfo = getTypeWitnessAndDecl (assocTypeReq, resolver );
183
+ const auto &TWInfo = getTypeWitnessAndDecl (assocTypeReq);
187
184
if (f (assocTypeReq, TWInfo.first , TWInfo.second ))
188
185
return true ;
189
186
}
@@ -193,13 +190,11 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
193
190
194
191
// / Retrieve the value witness declaration corresponding to the given
195
192
// / requirement.
196
- ValueDecl *getWitnessDecl (ValueDecl *requirement,
197
- LazyResolver *resolver) const ;
193
+ ValueDecl *getWitnessDecl (ValueDecl *requirement) const ;
198
194
199
195
// / Retrieve the witness corresponding to the given value requirement.
200
196
// / TODO: maybe this should return a Witness?
201
- ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement,
202
- LazyResolver *resolver) const ;
197
+ ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement) const ;
203
198
204
199
private:
205
200
// / Determine whether we have a witness for the given requirement.
@@ -211,7 +206,7 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
211
206
// /
212
207
// / The function object should accept a \c ValueDecl* for the requirement.
213
208
template <typename F>
214
- void forEachNonWitnessedRequirement (LazyResolver *Resolver, F f) const {
209
+ void forEachNonWitnessedRequirement (F f) const {
215
210
const ProtocolDecl *protocol = getProtocol ();
216
211
for (auto req : protocol->getMembers ()) {
217
212
auto valueReq = dyn_cast<ValueDecl>(req);
@@ -220,7 +215,7 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
220
215
221
216
if (auto assocTypeReq = dyn_cast<AssociatedTypeDecl>(req)) {
222
217
// If we don't have witness for the associated type, apply the function.
223
- if (getTypeWitness (assocTypeReq, Resolver )->hasError ()) {
218
+ if (getTypeWitness (assocTypeReq)->hasError ()) {
224
219
f (valueReq);
225
220
}
226
221
continue ;
@@ -241,15 +236,13 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance {
241
236
242
237
// / Given a dependent type expressed in terms of the self parameter,
243
238
// / map it into the context of this conformance.
244
- Type getAssociatedType (Type assocType,
245
- LazyResolver *resolver = nullptr ) const ;
239
+ Type getAssociatedType (Type assocType) const ;
246
240
247
241
// / Given that the requirement signature of the protocol directly states
248
242
// / that the given dependent type must conform to the given protocol,
249
243
// / return its associated conformance.
250
244
ProtocolConformanceRef
251
- getAssociatedConformance (Type assocType, ProtocolDecl *protocol,
252
- LazyResolver *resolver = nullptr ) const ;
245
+ getAssociatedConformance (Type assocType, ProtocolDecl *protocol) const ;
253
246
254
247
// / Get the generic parameters open on the conforming type.
255
248
GenericEnvironment *getGenericEnvironment () const ;
@@ -353,12 +346,11 @@ class RootProtocolConformance : public ProtocolConformance {
353
346
AvailabilityContext fromContext) const ;
354
347
355
348
bool hasWitness (ValueDecl *requirement) const ;
356
- Witness getWitness (ValueDecl *requirement, LazyResolver *resolver ) const ;
349
+ Witness getWitness (ValueDecl *requirement) const ;
357
350
358
351
// / Retrieve the witness corresponding to the given value requirement.
359
352
// / TODO: maybe this should return a Witness?
360
- ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement,
361
- LazyResolver *resolver) const ;
353
+ ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement) const ;
362
354
363
355
// / Apply the given function object to each value witness within this
364
356
// / protocol conformance.
@@ -368,7 +360,7 @@ class RootProtocolConformance : public ProtocolConformance {
368
360
// / witness will only be specialized if the conformance came from the current
369
361
// / file.
370
362
template <typename F>
371
- void forEachValueWitness (LazyResolver *resolver, F f ) const {
363
+ void forEachValueWitness (F f, bool useResolver= false ) const {
372
364
const ProtocolDecl *protocol = getProtocol ();
373
365
for (auto req : protocol->getMembers ()) {
374
366
auto valueReq = dyn_cast<ValueDecl>(req);
@@ -380,10 +372,10 @@ class RootProtocolConformance : public ProtocolConformance {
380
372
continue ;
381
373
382
374
// If we don't have and cannot resolve witnesses, skip it.
383
- if (!resolver && !hasWitness (valueReq))
375
+ if (!useResolver && !hasWitness (valueReq))
384
376
continue ;
385
377
386
- f (valueReq, getWitness (valueReq, resolver ));
378
+ f (valueReq, getWitness (valueReq));
387
379
}
388
380
}
389
381
@@ -597,13 +589,11 @@ class NormalProtocolConformance : public RootProtocolConformance,
597
589
// / for the given associated type.
598
590
std::pair<Type, TypeDecl *>
599
591
getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
600
- LazyResolver *resolver,
601
592
SubstOptions options = None) const ;
602
593
603
594
// / Determine whether the protocol conformance has a type witness for the
604
595
// / given associated type.
605
- bool hasTypeWitness (AssociatedTypeDecl *assocType,
606
- LazyResolver *resolver = nullptr ) const ;
596
+ bool hasTypeWitness (AssociatedTypeDecl *assocType) const ;
607
597
608
598
// / Set the type witness for the given associated type.
609
599
// / \param typeDecl the type decl the witness type came from, if one exists.
@@ -614,11 +604,10 @@ class NormalProtocolConformance : public RootProtocolConformance,
614
604
// / that the given dependent type must conform to the given protocol,
615
605
// / return its associated conformance.
616
606
ProtocolConformanceRef
617
- getAssociatedConformance (Type assocType, ProtocolDecl *protocol,
618
- LazyResolver *resolver = nullptr ) const ;
607
+ getAssociatedConformance (Type assocType, ProtocolDecl *protocol) const ;
619
608
620
609
// / Retrieve the value witness corresponding to the given requirement.
621
- Witness getWitness (ValueDecl *requirement, LazyResolver *resolver ) const ;
610
+ Witness getWitness (ValueDecl *requirement) const ;
622
611
623
612
// / Determine whether the protocol conformance has a witness for the given
624
613
// / requirement.
@@ -644,20 +633,14 @@ class NormalProtocolConformance : public RootProtocolConformance,
644
633
// / the normal conformance.
645
634
void setSignatureConformances (ArrayRef<ProtocolConformanceRef> conformances);
646
635
647
- // / Retrieves a function object that should be called with each of the
648
- // / conformances required by the requirement signature.
649
- // /
650
- // / This can be used to iteratively build up the signature conformances in
651
- // / the type checker (rather than emitting them in a batch via
652
- // / \c setSignatureConformances). The callee is responsible for calling
653
- // / the returned function object with protocol conformances that line up
654
- // / with the conformance requirements in the requirement signature (in order).
655
- std::function<void (ProtocolConformanceRef)> populateSignatureConformances ();
636
+ // / Populate the signature conformances without checking if they satisfy
637
+ // / requirements. Can only be used with parsed or imported conformances.
638
+ void finishSignatureConformances ();
656
639
657
640
// / Determine whether the witness for the given type requirement
658
641
// / is the default definition.
659
642
bool usesDefaultDefinition (AssociatedTypeDecl *requirement) const {
660
- TypeDecl *witnessDecl = getTypeWitnessAndDecl (requirement, nullptr ).second ;
643
+ TypeDecl *witnessDecl = getTypeWitnessAndDecl (requirement).second ;
661
644
if (witnessDecl)
662
645
return witnessDecl->isImplicit ();
663
646
// Conservatively assume it does not.
@@ -725,20 +708,17 @@ class SelfProtocolConformance : public RootProtocolConformance {
725
708
llvm_unreachable (" never an implied conformance" );
726
709
}
727
710
728
- bool hasTypeWitness (AssociatedTypeDecl *assocType,
729
- LazyResolver *resolver) const {
711
+ bool hasTypeWitness (AssociatedTypeDecl *assocType) const {
730
712
llvm_unreachable (" self-conformances never have associated types" );
731
713
}
732
714
733
715
std::pair<Type, TypeDecl *>
734
716
getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
735
- LazyResolver *resolver,
736
717
SubstOptions options) const {
737
718
llvm_unreachable (" self-conformances never have associated types" );
738
719
}
739
720
740
721
Type getTypeWitness (AssociatedTypeDecl *assocType,
741
- LazyResolver *resolver,
742
722
SubstOptions options) const {
743
723
llvm_unreachable (" self-conformances never have associated types" );
744
724
}
@@ -748,15 +728,14 @@ class SelfProtocolConformance : public RootProtocolConformance {
748
728
}
749
729
750
730
ProtocolConformanceRef getAssociatedConformance (Type assocType,
751
- ProtocolDecl *protocol,
752
- LazyResolver *resolver) const {
731
+ ProtocolDecl *protocol) const {
753
732
llvm_unreachable (" self-conformances never have associated types" );
754
733
}
755
734
756
735
bool hasWitness (ValueDecl *requirement) const {
757
736
return true ;
758
737
}
759
- Witness getWitness (ValueDecl *requirement, LazyResolver *resolver ) const ;
738
+ Witness getWitness (ValueDecl *requirement) const ;
760
739
761
740
Optional<ArrayRef<Requirement>> getConditionalRequirementsIfAvailable () const {
762
741
return ArrayRef<Requirement>();
@@ -875,26 +854,22 @@ class SpecializedProtocolConformance : public ProtocolConformance,
875
854
return GenericConformance->getImplyingConformance ();
876
855
}
877
856
878
- bool hasTypeWitness (AssociatedTypeDecl *assocType,
879
- LazyResolver *resolver = nullptr ) const ;
857
+ bool hasTypeWitness (AssociatedTypeDecl *assocType) const ;
880
858
881
859
// / Retrieve the type witness and type decl (if one exists)
882
860
// / for the given associated type.
883
861
std::pair<Type, TypeDecl *>
884
862
getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
885
- LazyResolver *resolver,
886
863
SubstOptions options = None) const ;
887
864
888
865
// / Given that the requirement signature of the protocol directly states
889
866
// / that the given dependent type must conform to the given protocol,
890
867
// / return its associated conformance.
891
868
ProtocolConformanceRef
892
- getAssociatedConformance (Type assocType, ProtocolDecl *protocol,
893
- LazyResolver *resolver = nullptr ) const ;
869
+ getAssociatedConformance (Type assocType, ProtocolDecl *protocol) const ;
894
870
895
871
// / Retrieve the witness corresponding to the given value requirement.
896
- ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement,
897
- LazyResolver *resolver) const ;
872
+ ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement) const ;
898
873
899
874
// / Determine whether the witness for the given requirement
900
875
// / is either the default definition or was otherwise deduced.
@@ -989,31 +964,26 @@ class InheritedProtocolConformance : public ProtocolConformance,
989
964
// / Get the protocol conformance which implied this implied conformance.
990
965
NormalProtocolConformance *getImplyingConformance () const { return nullptr ; }
991
966
992
- bool hasTypeWitness (AssociatedTypeDecl *assocType,
993
- LazyResolver *resolver = nullptr ) const {
994
- return InheritedConformance->hasTypeWitness (assocType, resolver);
967
+ bool hasTypeWitness (AssociatedTypeDecl *assocType) const {
968
+ return InheritedConformance->hasTypeWitness (assocType);
995
969
}
996
970
997
971
// / Retrieve the type witness and type decl (if one exists)
998
972
// / for the given associated type.
999
973
std::pair<Type, TypeDecl *>
1000
974
getTypeWitnessAndDecl (AssociatedTypeDecl *assocType,
1001
- LazyResolver *resolver,
1002
975
SubstOptions options = None) const {
1003
- return InheritedConformance->getTypeWitnessAndDecl (assocType, resolver,
1004
- options);
976
+ return InheritedConformance->getTypeWitnessAndDecl (assocType, options);
1005
977
}
1006
978
1007
979
// / Given that the requirement signature of the protocol directly states
1008
980
// / that the given dependent type must conform to the given protocol,
1009
981
// / return its associated conformance.
1010
982
ProtocolConformanceRef
1011
- getAssociatedConformance (Type assocType, ProtocolDecl *protocol,
1012
- LazyResolver *resolver = nullptr ) const ;
983
+ getAssociatedConformance (Type assocType, ProtocolDecl *protocol) const ;
1013
984
1014
985
// / Retrieve the witness corresponding to the given value requirement.
1015
- ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement,
1016
- LazyResolver *resolver) const ;
986
+ ConcreteDeclRef getWitnessDeclRef (ValueDecl *requirement) const ;
1017
987
1018
988
// / Determine whether the witness for the given requirement
1019
989
// / is either the default definition or was otherwise deduced.
0 commit comments