|
20 | 20 | #include "swift/AST/ASTContext.h"
|
21 | 21 | #include "swift/AST/DiagnosticsSema.h"
|
22 | 22 | #include "swift/AST/DiagnosticEngine.h"
|
| 23 | +#include "swift/AST/ExistentialLayout.h" |
23 | 24 | #include "swift/AST/GenericEnvironment.h"
|
24 | 25 | #include "swift/AST/Module.h"
|
25 | 26 | #include "swift/AST/ParameterList.h"
|
@@ -2520,12 +2521,22 @@ bool GenericSignatureBuilder::addTypeRequirement(
|
2520 | 2521 |
|
2521 | 2522 | // Protocol requirements.
|
2522 | 2523 | if (constraintType->isExistentialType()) {
|
2523 |
| - // FIXME: "Class" or arbitrary layout requirements. |
2524 |
| - SmallVector<ProtocolDecl *, 4> protocols; |
2525 |
| - (void)constraintType->getExistentialTypeProtocols(protocols); |
2526 | 2524 | bool anyErrors = false;
|
2527 |
| - for (auto proto : protocols) { |
2528 |
| - if (addConformanceRequirement(subjectPA, proto, resolvedSource, |
| 2525 | + |
| 2526 | + auto layout = constraintType->getExistentialLayout(); |
| 2527 | + |
| 2528 | + assert((!layout.requiresClass || layout.requiresClassImplied) && |
| 2529 | + "explicit AnyObject not yet supported"); |
| 2530 | + |
| 2531 | + if (layout.superclass) { |
| 2532 | + if (addSuperclassRequirementDirect(subjectPA, layout.superclass, |
| 2533 | + resolvedSource)) |
| 2534 | + anyErrors = true; |
| 2535 | + } |
| 2536 | + |
| 2537 | + for (auto *proto : layout.getProtocols()) { |
| 2538 | + auto *protoDecl = proto->getDecl(); |
| 2539 | + if (addConformanceRequirement(subjectPA, protoDecl, resolvedSource, |
2529 | 2540 | *visited))
|
2530 | 2541 | anyErrors = true;
|
2531 | 2542 | }
|
|
0 commit comments