Skip to content

Commit 46a9061

Browse files
committed
upon cycle detection, say it's noncopyable
1 parent e8e82eb commit 46a9061

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/AST/Decl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3398,9 +3398,13 @@ bool ValueDecl::isFinal() const {
33983398
}
33993399

34003400
bool ValueDecl::isMoveOnly() const {
3401+
// Default answer if a cycle is detected is to say it is noncopyable.
3402+
// My reasoning is that permitting copying when the user _might_ have intended
3403+
// for it to be noncopyable is unacceptable as it can lead to silent problems.
3404+
// At least they'll get unexpected errors if they were expecting to copy!
34013405
return evaluateOrDefault(getASTContext().evaluator,
34023406
IsMoveOnlyRequest{const_cast<ValueDecl *>(this)},
3403-
getAttrs().hasAttribute<MoveOnlyAttr>());
3407+
/*noncopyable=*/true);
34043408
}
34053409

34063410
bool TypeDecl::isSuppressingConformance(KnownProtocolKind kp) const {

0 commit comments

Comments
 (0)