Skip to content

Commit 00b2168

Browse files
committed
NCGenerics: improve assertion messages
1 parent bd3c15e commit 00b2168

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4897,7 +4897,7 @@ InverseMarking TypeDecl::getMarking(InvertibleProtocolKind ip) const {
48974897
static TypeDecl::CanBeInvertible::Result
48984898
conformanceExists(TypeDecl const *decl, InvertibleProtocolKind ip) {
48994899
auto *proto = decl->getASTContext().getProtocol(getKnownProtocolKind(ip));
4900-
assert(proto);
4900+
assert(proto && "missing Copyable/Escapable from stdlib!");
49014901

49024902
// Handle protocols specially, without building a GenericSignature.
49034903
if (auto *protoDecl = dyn_cast<ProtocolDecl>(decl))

lib/AST/Requirement.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,7 @@ void InverseRequirement::expandDefaults(
358358
auto protos = InverseRequirement::expandDefault(gp);
359359
for (auto ip : protos) {
360360
auto proto = ctx.getProtocol(getKnownProtocolKind(ip));
361-
if (!proto)
362-
llvm_unreachable("failed to load Copyable/Escapable/etc from stdlib!");
361+
assert(proto && "missing Copyable/Escapable from stdlib!");
363362

364363
auto protoTy = proto->getDeclaredInterfaceType();
365364
result.push_back({{RequirementKind::Conformance, gp, protoTy},

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static void expandDefaultProtocols(
388388
continue;
389389

390390
auto proto = ctx.getProtocol(getKnownProtocolKind(ip));
391-
assert(proto);
391+
assert(proto && "missing Copyable/Escapable from stdlib!");
392392

393393
protocols.push_back(proto);
394394
}

lib/Sema/TypeCheckInvertible.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
161161
static bool conformsToInvertible(CanType type, InvertibleProtocolKind ip) {
162162
auto &ctx = type->getASTContext();
163163

164-
auto *invertible = ctx.getProtocol(getKnownProtocolKind(ip));
165-
assert(invertible && "failed to load Copyable/Escapable from stdlib!");
164+
auto *proto = ctx.getProtocol(getKnownProtocolKind(ip));
165+
assert(proto && "missing Copyable/Escapable from stdlib!");
166166

167167
// Must not have a type parameter!
168168
assert(!type->hasTypeParameter() && "caller forgot to mapTypeIntoContext!");
@@ -177,8 +177,8 @@ static bool conformsToInvertible(CanType type, InvertibleProtocolKind ip) {
177177
SILTokenType>()));
178178

179179
const bool conforms =
180-
(bool) invertible->getParentModule()->checkConformance(
181-
type, invertible,
180+
(bool) proto->getParentModule()->checkConformance(
181+
type, proto,
182182
/*allowMissing=*/false);
183183

184184
return conforms;

0 commit comments

Comments
 (0)