@@ -708,6 +708,23 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
708708 return getSILLinkage (getDeclLinkage (getterDecl), forDefinition);
709709 }
710710
711+ case Kind::OpaqueTypeDescriptor: {
712+ auto *opaqueType = cast<OpaqueTypeDecl>(getDecl ());
713+
714+ // The opaque result type descriptor with availability conditions
715+ // has to be emitted into a client module when associated with
716+ // `@_alwaysEmitIntoClient` declaration which means it's linkage
717+ // has to be "shared".
718+ if (opaqueType->hasConditionallyAvailableSubstitutions ()) {
719+ if (auto *srcDecl = opaqueType->getNamingDecl ()) {
720+ if (srcDecl->getAttrs ().hasAttribute <AlwaysEmitIntoClientAttr>())
721+ return SILLinkage::Shared;
722+ }
723+ }
724+
725+ return getSILLinkage (getDeclLinkage (opaqueType), forDefinition);
726+ }
727+
711728 case Kind::AssociatedConformanceDescriptor:
712729 case Kind::BaseConformanceDescriptor:
713730 case Kind::ObjCClass:
@@ -720,7 +737,6 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
720737 case Kind::ProtocolDescriptorRecord:
721738 case Kind::ProtocolRequirementsBaseDescriptor:
722739 case Kind::MethodLookupFunction:
723- case Kind::OpaqueTypeDescriptor:
724740 case Kind::OpaqueTypeDescriptorRecord:
725741 case Kind::OpaqueTypeDescriptorAccessor:
726742 case Kind::OpaqueTypeDescriptorAccessorImpl:
0 commit comments