Skip to content

Commit fad62cb

Browse files
committed
[CSSimplify] Avoid checking conditional conformances in simplifyTransitivelyConformsTo
It's not always clear what generic parameter type implicit conversion to pointer is going to have, and its safer to check direct conformance in `simplifyTransitivelyConformsTo` and let parameter handle the rest.
1 parent 5f2fdc9 commit fad62cb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#include "CSDiagnostics.h"
19+
#include "swift/AST/Decl.h"
1920
#include "swift/AST/ExistentialLayout.h"
2021
#include "swift/AST/GenericEnvironment.h"
2122
#include "swift/AST/GenericSignature.h"
@@ -6253,9 +6254,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
62536254

62546255
auto *protocol = protocolTy->castTo<ProtocolType>()->getDecl();
62556256

6257+
auto *M = DC->getParentModule();
6258+
62566259
// First, let's check whether the type itself conforms,
62576260
// if it does - we are done.
6258-
if (TypeChecker::conformsToProtocol(resolvedTy, protocol, DC))
6261+
if (M->lookupConformance(resolvedTy, protocol))
62596262
return SolutionKind::Solved;
62606263

62616264
// If the type doesn't conform, let's check whether
@@ -6294,11 +6297,10 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
62946297
}
62956298
}
62966299

6297-
return llvm::any_of(
6298-
typesToCheck,
6299-
[&](Type type) {
6300-
return bool(TypeChecker::conformsToProtocol(type, protocol, DC));
6301-
})
6300+
return llvm::any_of(typesToCheck,
6301+
[&](Type type) {
6302+
return bool(M->lookupConformance(type, protocol));
6303+
})
63026304
? SolutionKind::Solved
63036305
: SolutionKind::Error;
63046306
}

0 commit comments

Comments
 (0)