|
23 | 23 | #include "swift/AST/FileUnit.h"
|
24 | 24 | #include "swift/AST/GenericEnvironment.h"
|
25 | 25 | #include "swift/AST/InFlightSubstitution.h"
|
| 26 | +#include "swift/AST/InverseMarking.h" |
26 | 27 | #include "swift/AST/LazyResolver.h"
|
27 | 28 | #include "swift/AST/Module.h"
|
28 | 29 | #include "swift/AST/PackConformance.h"
|
@@ -1091,6 +1092,16 @@ void NominalTypeDecl::prepareConformanceTable() const {
|
1091 | 1092 | }
|
1092 | 1093 | };
|
1093 | 1094 |
|
| 1095 | + // Synthesize the unconditional conformances to invertible protocols. |
| 1096 | + // For conditional ones, see findSynthesizedConformances . |
| 1097 | + if (haveNoncopyableGenerics) { |
| 1098 | + for (auto ip : InvertibleProtocolSet::full()) { |
| 1099 | + auto invertible = getMarking(ip); |
| 1100 | + if (!invertible.getInverse() || bool(invertible.getPositive())) |
| 1101 | + addSynthesized(ctx.getProtocol(getKnownProtocolKind(ip))); |
| 1102 | + } |
| 1103 | + } |
| 1104 | + |
1094 | 1105 | // Add protocols for any synthesized protocol attributes.
|
1095 | 1106 | for (auto attr : getAttrs().getAttributes<SynthesizedProtocolAttr>()) {
|
1096 | 1107 | addSynthesized(attr->getProtocol());
|
@@ -1263,9 +1274,12 @@ static SmallVector<ProtocolConformance *, 2> findSynthesizedConformances(
|
1263 | 1274 | if (!isa<ProtocolDecl>(nominal)) {
|
1264 | 1275 | trySynthesize(KnownProtocolKind::Sendable);
|
1265 | 1276 |
|
1266 |
| - if (nominal->getASTContext().LangOpts.hasFeature(Feature::NoncopyableGenerics)) { |
1267 |
| - trySynthesize(KnownProtocolKind::Copyable); |
1268 |
| - trySynthesize(KnownProtocolKind::Escapable); |
| 1277 | + // Triggers synthesis of a possibly conditional conformance. |
| 1278 | + // For the unconditional ones, see NominalTypeDecl::prepareConformanceTable |
| 1279 | + if (nominal->getASTContext().LangOpts.hasFeature( |
| 1280 | + Feature::NoncopyableGenerics)) { |
| 1281 | + for (auto ip : InvertibleProtocolSet::full()) |
| 1282 | + trySynthesize(getKnownProtocolKind(ip)); |
1269 | 1283 | }
|
1270 | 1284 |
|
1271 | 1285 | if (nominal->getASTContext().LangOpts.hasFeature(
|
|
0 commit comments