Skip to content

Commit 0ba4e33

Browse files
committed
[NFC] Lambda-fy an Assertion
1 parent 3946977 commit 0ba4e33

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/Sema/DerivedConformanceRawRepresentable.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,15 @@ deriveRawRepresentable_init(DerivedConformance &derived) {
401401
auto rawInterfaceType = enumDecl->getRawType();
402402
auto rawType = parentDC->mapTypeIntoContext(rawInterfaceType);
403403

404-
auto equatableProto = TypeChecker::getProtocol(C, enumDecl->getLoc(),
405-
KnownProtocolKind::Equatable);
406-
assert(equatableProto);
407-
assert(
408-
TypeChecker::conformsToProtocol(rawType, equatableProto, enumDecl));
409-
(void)equatableProto;
410-
(void)rawType;
404+
405+
assert([&]() -> bool {
406+
auto equatableProto = TypeChecker::getProtocol(C, enumDecl->getLoc(),
407+
KnownProtocolKind::Equatable);
408+
if (!equatableProto) {
409+
return false;
410+
}
411+
return !TypeChecker::conformsToProtocol(rawType, equatableProto, enumDecl).isInvalid();
412+
}());
411413

412414
auto *rawDecl = new (C)
413415
ParamDecl(SourceLoc(), SourceLoc(),

0 commit comments

Comments
 (0)