@@ -41,7 +41,7 @@ DeclContext *ConformanceLookupTable::ConformanceSource::getDeclContext() const {
4141 return getImpliedSource ()->Source .getDeclContext ();
4242
4343 case ConformanceEntryKind::Synthesized:
44- return getSynthesizedDecl ();
44+ return getSynthesizedDeclContext ();
4545 }
4646
4747 llvm_unreachable (" Unhandled ConformanceEntryKind in switch." );
@@ -241,6 +241,14 @@ void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,
241241 auto addInheritedConformance = [&](ConformanceEntry *entry) {
242242 auto protocol = entry->getProtocol ();
243243
244+ // Don't add unavailable conformances.
245+ if (auto dc = entry->Source .getDeclContext ()) {
246+ if (auto ext = dyn_cast<ExtensionDecl>(dc)) {
247+ if (AvailableAttr::isUnavailable (ext))
248+ return ;
249+ }
250+ }
251+
244252 // Don't add redundant conformances here. This is merely an
245253 // optimization; resolveConformances() would zap the duplicates
246254 // anyway.
@@ -812,7 +820,8 @@ DeclContext *ConformanceLookupTable::getConformingContext(
812820 if (superclassTy->is <ErrorType>())
813821 return nullptr ;
814822 auto inheritedConformance = module ->lookupConformance (
815- superclassTy, protocol);
823+ superclassTy, protocol, /* allowMissing=*/ false ,
824+ /* allowUnavailable=*/ false );
816825 if (inheritedConformance)
817826 return superclassDecl;
818827 } while ((superclassDecl = superclassDecl->getSuperclassDecl ()));
@@ -927,10 +936,11 @@ ConformanceLookupTable::getConformance(NominalTypeDecl *nominal,
927936 return entry->Conformance .get <ProtocolConformance *>();
928937}
929938
930- void ConformanceLookupTable::addSynthesizedConformance (NominalTypeDecl *nominal,
931- ProtocolDecl *protocol) {
939+ void ConformanceLookupTable::addSynthesizedConformance (
940+ NominalTypeDecl *nominal, ProtocolDecl *protocol,
941+ DeclContext *conformanceDC) {
932942 addProtocol (protocol, nominal->getLoc (),
933- ConformanceSource::forSynthesized (nominal ));
943+ ConformanceSource::forSynthesized (conformanceDC ));
934944}
935945
936946void ConformanceLookupTable::registerProtocolConformance (
@@ -956,7 +966,7 @@ void ConformanceLookupTable::registerProtocolConformance(
956966 auto inherited = dyn_cast<InheritedProtocolConformance>(conformance);
957967 ConformanceSource source
958968 = inherited ? ConformanceSource::forInherited (cast<ClassDecl>(nominal)) :
959- synthesized ? ConformanceSource::forSynthesized (nominal ) :
969+ synthesized ? ConformanceSource::forSynthesized (dc ) :
960970 ConformanceSource::forExplicit (dc);
961971
962972 ASTContext &ctx = nominal->getASTContext ();
0 commit comments