|
20 | 20 | #include "TypoCorrection.h"
|
21 | 21 | #include "swift/AST/ASTContext.h"
|
22 | 22 | #include "swift/AST/Decl.h"
|
| 23 | +#include "swift/AST/ExistentialLayout.h" |
23 | 24 | #include "swift/AST/Expr.h"
|
24 | 25 | #include "swift/AST/GenericSignature.h"
|
25 | 26 | #include "swift/AST/Initializer.h"
|
@@ -2452,12 +2453,7 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
|
2452 | 2453 | // is a struct), then bail out instead of offering a broken fix-it later on.
|
2453 | 2454 | auto requiresClass = false;
|
2454 | 2455 | if (unwrappedToType->isExistentialType()) {
|
2455 |
| - if (auto protocolTy = unwrappedToType->getAs<ProtocolType>()) { |
2456 |
| - requiresClass = protocolTy->requiresClass(); |
2457 |
| - } else if (auto compositionTy = |
2458 |
| - unwrappedToType->getAs<ProtocolCompositionType>()) { |
2459 |
| - requiresClass = compositionTy->requiresClass(); |
2460 |
| - } |
| 2456 | + requiresClass = unwrappedToType->getExistentialLayout().requiresClass(); |
2461 | 2457 | }
|
2462 | 2458 | if (requiresClass && !FromType->is<ClassType>()) {
|
2463 | 2459 | return false;
|
@@ -2486,7 +2482,6 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
|
2486 | 2482 | missingProtoTypeStrings.push_back(memberTy->getString());
|
2487 | 2483 | }
|
2488 | 2484 | }
|
2489 |
| - |
2490 | 2485 | // If we don't conform to all of the protocols in the composition, then
|
2491 | 2486 | // store the composition type only. This is because we need to append
|
2492 | 2487 | // 'Foo & Bar' instead of 'Foo, Bar' in order to match the written type.
|
|
0 commit comments