@@ -147,6 +147,42 @@ bool SILModule::isTypeMetadataAccessible(CanType type) {
147
147
});
148
148
}
149
149
150
+ // / Return the formal linkage of the component restrictions of this
151
+ // / generic signature. Never returns PublicUnique.
152
+ FormalLinkage swift::getGenericSignatureLinkage (CanGenericSignature sig) {
153
+ // This can only be PublicNonUnique or HiddenUnique. Signatures can
154
+ // never be PublicUnique in the first place, and we short-circuit on
155
+ // Private. So we only ever update it when we see HiddenUnique linkage.
156
+ FormalLinkage linkage = FormalLinkage::PublicNonUnique;
157
+
158
+ for (auto &req : sig.getRequirements ()) {
159
+ // The first type can be ignored because it should always be
160
+ // a dependent type.
161
+
162
+ switch (req.getKind ()) {
163
+ case RequirementKind::Layout:
164
+ continue ;
165
+
166
+ case RequirementKind::Conformance:
167
+ case RequirementKind::SameType:
168
+ case RequirementKind::Superclass:
169
+ switch (getTypeLinkage (CanType (req.getSecondType ()))) {
170
+ case FormalLinkage::PublicUnique:
171
+ case FormalLinkage::PublicNonUnique:
172
+ continue ;
173
+ case FormalLinkage::HiddenUnique:
174
+ linkage = FormalLinkage::HiddenUnique;
175
+ continue ;
176
+ case FormalLinkage::Private:
177
+ // We can short-circuit with this.
178
+ return linkage;
179
+ }
180
+ }
181
+ }
182
+
183
+ return linkage;
184
+ }
185
+
150
186
// / Return the minimum linkage structurally required to reference the given formal type.
151
187
FormalLinkage swift::getTypeLinkage (CanType t) {
152
188
assert (t->isLegalFormalType ());
0 commit comments