@@ -723,6 +723,23 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
723723 return getSILLinkage (getDeclLinkage (getterDecl), forDefinition);
724724 }
725725
726+ case Kind::OpaqueTypeDescriptor: {
727+ auto *opaqueType = cast<OpaqueTypeDecl>(getDecl ());
728+
729+ // The opaque result type descriptor with availability conditions
730+ // has to be emitted into a client module when associated with
731+ // `@_alwaysInlineIntoClient` declaration which means it's linkage
732+ // has to be "shared".
733+ if (opaqueType->hasConditionallyAvailableSubstitutions ()) {
734+ if (auto *srcDecl = opaqueType->getNamingDecl ()) {
735+ if (srcDecl->getAttrs ().hasAttribute <AlwaysEmitIntoClientAttr>())
736+ return SILLinkage::Shared;
737+ }
738+ }
739+
740+ return getSILLinkage (getDeclLinkage (opaqueType), forDefinition);
741+ }
742+
726743 case Kind::AssociatedConformanceDescriptor:
727744 case Kind::BaseConformanceDescriptor:
728745 case Kind::ObjCClass:
@@ -735,7 +752,6 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
735752 case Kind::ProtocolDescriptorRecord:
736753 case Kind::ProtocolRequirementsBaseDescriptor:
737754 case Kind::MethodLookupFunction:
738- case Kind::OpaqueTypeDescriptor:
739755 case Kind::OpaqueTypeDescriptorRecord:
740756 case Kind::OpaqueTypeDescriptorAccessor:
741757 case Kind::OpaqueTypeDescriptorAccessorImpl:
0 commit comments