@@ -821,7 +821,19 @@ ModuleDecl::lookupExistentialConformance(Type type, ProtocolDecl *protocol) {
821
821
822
822
ProtocolConformanceRef ModuleDecl::lookupConformance (Type type,
823
823
ProtocolDecl *protocol) {
824
- ASTContext &ctx = getASTContext ();
824
+ return evaluateOrDefault (
825
+ getASTContext ().evaluator ,
826
+ LookupConformanceInModuleRequest{{this , type, protocol}},
827
+ ProtocolConformanceRef::forInvalid ());
828
+ }
829
+
830
+ llvm::Expected<ProtocolConformanceRef>
831
+ LookupConformanceInModuleRequest::evaluate (
832
+ Evaluator &evaluator, LookupConformanceDescriptor desc) const {
833
+ auto *mod = desc.Mod ;
834
+ auto type = desc.Ty ;
835
+ auto protocol = desc.PD ;
836
+ ASTContext &ctx = mod->getASTContext ();
825
837
826
838
// A dynamic Self type conforms to whatever its underlying type
827
839
// conforms to.
@@ -839,7 +851,7 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
839
851
// able to be resolved by a substitution that makes the archetype
840
852
// concrete.
841
853
if (auto super = archetype->getSuperclass ()) {
842
- if (auto inheritedConformance = lookupConformance (super, protocol)) {
854
+ if (auto inheritedConformance = mod-> lookupConformance (super, protocol)) {
843
855
return ProtocolConformanceRef (ctx.getInheritedConformance (
844
856
type, inheritedConformance.getConcrete ()));
845
857
}
@@ -857,7 +869,7 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
857
869
// existential's list of conformances and the existential conforms to
858
870
// itself.
859
871
if (type->isExistentialType ())
860
- return lookupExistentialConformance (type, protocol);
872
+ return mod-> lookupExistentialConformance (type, protocol);
861
873
862
874
// Type variables have trivial conformances.
863
875
if (type->isTypeVariableOrMember ())
@@ -877,7 +889,7 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
877
889
878
890
// Find the (unspecialized) conformance.
879
891
SmallVector<ProtocolConformance *, 2 > conformances;
880
- if (!nominal->lookupConformance (this , protocol, conformances))
892
+ if (!nominal->lookupConformance (mod , protocol, conformances))
881
893
return ProtocolConformanceRef::forInvalid ();
882
894
883
895
// FIXME: Ambiguity resolution.
@@ -897,7 +909,7 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
897
909
auto superclassTy = type->getSuperclassForDecl (conformingClass);
898
910
899
911
// Compute the conformance for the inherited type.
900
- auto inheritedConformance = lookupConformance (superclassTy, protocol);
912
+ auto inheritedConformance = mod-> lookupConformance (superclassTy, protocol);
901
913
assert (inheritedConformance &&
902
914
" We already found the inherited conformance" );
903
915
@@ -918,7 +930,7 @@ ProtocolConformanceRef ModuleDecl::lookupConformance(Type type,
918
930
if (!explicitConformanceType->isEqual (type)) {
919
931
// Gather the substitutions we need to map the generic conformance to
920
932
// the specialized conformance.
921
- auto subMap = type->getContextSubstitutionMap (this , explicitConformanceDC);
933
+ auto subMap = type->getContextSubstitutionMap (mod , explicitConformanceDC);
922
934
923
935
// Create the specialized conformance entry.
924
936
auto result = ctx.getSpecializedConformance (type, conformance, subMap);
0 commit comments