@@ -959,6 +959,13 @@ namespace {
959
959
}
960
960
961
961
void addAssociatedConformance (const AssociatedConformance &req) {
962
+ if (req.getAssociation ()->getASTContext ().LangOpts .hasFeature (Feature::Embedded) &&
963
+ !req.getAssociatedRequirement ()->requiresClass ()) {
964
+ // If it's not a class protocol, the associated type can never be used to create
965
+ // an existential. Therefore this witness entry is never used at runtime
966
+ // in embedded swift.
967
+ return ;
968
+ }
962
969
Entries.push_back (WitnessTableEntry::forAssociatedConformance (req));
963
970
}
964
971
@@ -1748,6 +1755,14 @@ class AccessorConformanceInfo : public ConformanceInfo {
1748
1755
(void )entry;
1749
1756
SILEntries = SILEntries.slice (1 );
1750
1757
1758
+ if (IGM.Context .LangOpts .hasFeature (Feature::Embedded) &&
1759
+ !requirement.getAssociatedRequirement ()->requiresClass ()) {
1760
+ // If it's not a class protocol, the associated type can never be used to create
1761
+ // an existential. Therefore this witness entry is never used at runtime
1762
+ // in embedded swift.
1763
+ return ;
1764
+ }
1765
+
1751
1766
auto associate =
1752
1767
ConformanceInContext.getAssociatedType (
1753
1768
requirement.getAssociation ())->getCanonicalType ();
@@ -1775,7 +1790,10 @@ class AccessorConformanceInfo : public ConformanceInfo {
1775
1790
if (IGM.Context .LangOpts .hasFeature (Feature::Embedded)) {
1776
1791
// In Embedded Swift associated-conformance entries simply point to the witness table
1777
1792
// of the associated conformance.
1778
- llvm::Constant *witnessEntry = IGM.getAddrOfWitnessTable (associatedConformance.getConcrete ());
1793
+ ProtocolConformanceRef assocConf =
1794
+ SILWT->getConformance ()->getAssociatedConformance (requirement.getAssociation (),
1795
+ requirement.getAssociatedRequirement ());
1796
+ llvm::Constant *witnessEntry = IGM.getAddrOfWitnessTable (assocConf.getConcrete ());
1779
1797
auto &schema = IGM.getOptions ().PointerAuth
1780
1798
.ProtocolAssociatedTypeWitnessTableAccessFunctions ;
1781
1799
Table.addSignedPointer (witnessEntry, schema, requirement);
@@ -3734,7 +3752,7 @@ llvm::Value *irgen::emitWitnessTableRef(IRGenFunction &IGF,
3734
3752
3735
3753
// In Embedded Swift, only class-bound wtables are allowed.
3736
3754
if (srcType->getASTContext ().LangOpts .hasFeature (Feature::Embedded)) {
3737
- assert (proto->requiresClass ());
3755
+ ASSERT (proto->requiresClass ());
3738
3756
}
3739
3757
3740
3758
assert (Lowering::TypeConverter::protocolRequiresWitnessTable (proto)
0 commit comments