Skip to content

Commit 2920ef3

Browse files
committed
[Sema] simplify IsNoncopyableRequest::evaluate
1 parent 89c10f9 commit 2920ef3

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ class HasNoncopyableAnnotationRequest
428428
void cacheResult(bool value) const;
429429
};
430430

431-
/// Determine whether the given type is noncopyable. Assumes type parameters
432-
/// have become archetypes.
431+
/// Determine whether the given type is noncopyable.
432+
/// Assumes a generic signature has been built.
433433
class IsNoncopyableRequest
434434
: public SimpleRequest<IsNoncopyableRequest, bool(CanType),
435435
RequestFlags::Cached> {

lib/Sema/TypeCheckInvertible.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,17 @@ static void tryEmitContainmentFixits(NominalTypeDecl *enclosingNom,
131131

132132
bool IsNoncopyableRequest::evaluate(Evaluator &evaluator,
133133
CanType type) const {
134-
assert(!type->hasTypeParameter() // && !type->hasUnboundGenericType()
135-
&& "forgot to mapTypeIntoContext first");
134+
assert(!type->hasTypeParameter() && "forgot to mapTypeIntoContext first");
136135
auto &ctx = type->getASTContext();
137136

138-
auto *protocol =
139-
TypeChecker::getProtocol(ctx, SourceLoc(), KnownProtocolKind::Copyable);
140-
if (!protocol)
137+
auto *copyable = ctx.getProtocol(KnownProtocolKind::Copyable);
138+
if (!copyable)
141139
llvm_unreachable("missing Copyable protocol!");
142140

143141
const bool conforms =
144142
(bool)TypeChecker::conformsToProtocol(type,
145-
protocol,
146-
protocol->getParentModule(),
143+
copyable,
144+
copyable->getParentModule(),
147145
/*allowMissing=*/false);
148146

149147
return !conforms;

0 commit comments

Comments
 (0)