Skip to content

Commit c67645f

Browse files
committed
NCGenerics: handle @_moveOnly correctly
We let TypeCheckAttr diagnose illega uses of the attribute. In addition, we need to exclude protocols from inferring a marking, because when we build the StructuralRequirements for a protocol, we ignore the "marking" this we'll miss this legacy attribute. fixes Sema/moveonly_decl_attr.swift
1 parent f98b211 commit c67645f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/Sema/TypeCheckDecl.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -927,13 +927,12 @@ InvertibleAnnotationRequest::evaluate(Evaluator &evaluator,
927927

928928
switch (TARGET) {
929929
case InvertibleProtocolKind::Copyable:
930-
// Handle the legacy '@_moveOnly' attribute
931-
if (auto attr = decl->getAttrs().getAttribute<MoveOnlyAttr>()) {
932-
assert((isa<StructDecl, EnumDecl, ClassDecl>(decl)));
933-
934-
return InverseMarking::forInverse(Kind::LegacyExplicit,
935-
attr->getLocation());
936-
}
930+
// Handle the legacy '@_moveOnly' for types they can validly appear.
931+
// TypeCheckAttr handles the illegal situations for us.
932+
if (auto attr = decl->getAttrs().getAttribute<MoveOnlyAttr>())
933+
if (isa<StructDecl, EnumDecl, ClassDecl>(decl))
934+
return InverseMarking::forInverse(Kind::LegacyExplicit,
935+
attr->getLocation());
937936
break;
938937

939938
case InvertibleProtocolKind::Escapable:

0 commit comments

Comments
 (0)