Skip to content

Commit 0c9d948

Browse files
committed
[Sema] bring back fast-path for isNoncopyable(DC)
Turns out my caching was busted and `requiresProtocol` is fast enough to go without it.
1 parent ef5976c commit 0c9d948

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

lib/AST/Type.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,29 +181,20 @@ static bool alwaysNoncopyable(Type ty) {
181181
/// context to substitute unbound types.
182182
bool TypeBase::isNoncopyable(const DeclContext *dc) {
183183
assert(dc);
184+
auto &ctx = dc->getASTContext();
184185

185-
/** FIXME: seems this is busted :(
186-
// Fast-path for type parameters; ask the generic signature directly and
187-
// cache that answer.
188-
if (isTypeParameter()) {
186+
// Fast-path for type parameters; ask the generic signature directly.
187+
if (isTypeParameter() &&
188+
ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
189189
auto canType = getCanonicalType();
190-
auto &ctx = canType->getASTContext();
191-
IsNoncopyableRequest req {canType};
192190

193-
if (ctx.evaluator.hasCachedResult(req))
194-
return evaluateOrDefault(ctx.evaluator, req, true);
195-
196-
auto *copyableProto = ctx.getProtocol(KnownProtocolKind::Copyable);
197-
if (!copyableProto)
191+
auto *copyable = ctx.getProtocol(KnownProtocolKind::Copyable);
192+
if (!copyable)
198193
llvm_unreachable("missing Copyable protocol!");
199194

200195
auto sig = dc->getGenericSignatureOfContext();
201-
bool isNoncopyable = !sig->requiresProtocol(canType, copyableProto);
202-
ctx.evaluator.cacheOutput(req, isNoncopyable == true);
203-
204-
return isNoncopyable;
196+
return !sig->requiresProtocol(canType, copyable);
205197
}
206-
*/
207198

208199
if (!hasArchetype() || hasOpenedExistential())
209200
// TODO: the need for the following test is suspicious.

0 commit comments

Comments
 (0)