@@ -215,7 +215,7 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) {
215215 return {Unsupported, UnrepresentableObjC};
216216 if (getActorIsolation (const_cast <ValueDecl *>(VD)).isActorIsolated ())
217217 return {Unsupported, UnrepresentableIsolatedInActor};
218- llvm::Optional<CanGenericSignature> genericSignature;
218+ GenericSignature genericSignature;
219219 // Don't expose @_alwaysEmitIntoClient decls as they require their
220220 // bodies to be emitted into client.
221221 if (VD->getAttrs ().hasAttribute <AlwaysEmitIntoClientAttr>())
@@ -228,7 +228,7 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) {
228228 Feature::GenerateBindingsForThrowingFunctionsInCXX))
229229 return {Unsupported, UnrepresentableThrows};
230230 if (AFD->isGeneric ())
231- genericSignature = AFD->getGenericSignature (). getCanonicalSignature () ;
231+ genericSignature = AFD->getGenericSignature ();
232232 }
233233 if (const auto *typeDecl = dyn_cast<NominalTypeDecl>(VD)) {
234234 if (isa<ProtocolDecl>(typeDecl))
@@ -239,8 +239,7 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) {
239239 if (typeDecl->isGeneric ()) {
240240 if (isa<ClassDecl>(VD))
241241 return {Unsupported, UnrepresentableGeneric};
242- genericSignature =
243- typeDecl->getGenericSignature ().getCanonicalSignature ();
242+ genericSignature = typeDecl->getGenericSignature ();
244243 }
245244 // Nested types are not yet supported.
246245 if (!typeDecl->hasClangNode () &&
@@ -280,9 +279,24 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) {
280279 }
281280 }
282281 }
282+
283283 // Generic requirements are not yet supported in C++.
284- if (genericSignature && !genericSignature->getRequirements ().empty ())
285- return {Unsupported, UnrepresentableGenericRequirements};
284+ if (genericSignature) {
285+
286+ // FIXME: We're using getRequirementsWithInverses() here as a shortcut for
287+ // checking for "no requirements except the implied Copyable ones".
288+ //
289+ // Eventually you don't want to call getRequirementsWithInverses() at all;
290+ // instead, the code here should walk the desugared requirements of the
291+ // signature directly and handle everything.
292+ SmallVector<Requirement, 2 > reqs;
293+ SmallVector<InverseRequirement, 2 > inverseReqs;
294+ genericSignature->getRequirementsWithInverses (reqs, inverseReqs);
295+ assert (inverseReqs.empty () && " Non-copyable generics not supported here!" );
296+ if (!reqs.empty ())
297+ return {Unsupported, UnrepresentableGenericRequirements};
298+ }
299+
286300 return {Representable, llvm::None};
287301}
288302
0 commit comments