Skip to content

Commit 4de861a

Browse files
committed
Diags: say "actors" cannot be ~Copyable
rdar://130450351 (cherry picked from commit 05f5e51)
1 parent 94425eb commit 4de861a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7672,8 +7672,8 @@ ERROR(inverse_associatedtype_restriction, none,
76727672
"cannot suppress '%0' requirement of an associated type",
76737673
(StringRef))
76747674
ERROR(inverse_on_class, none,
7675-
"classes cannot be '~%0'",
7676-
(StringRef))
7675+
"%select{classes|actors}1 cannot be '~%0'",
7676+
(StringRef, bool))
76777677
ERROR(inverse_with_class_constraint, none,
76787678
"composition involving %select{class requirement %2|'AnyObject'}0 "
76797679
"cannot contain '~%1'",

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
33453345

33463346
ctx.Diags.diagnose(decl->getLoc(),
33473347
diag::inverse_on_class,
3348-
getProtocolName(getKnownProtocolKind(ip)));
3348+
getProtocolName(getKnownProtocolKind(ip)),
3349+
decl->isAnyActor());
33493350
}
33503351
}
33513352

test/Generics/inverse_classes2.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// RUN: %target-typecheck-verify-swift \
2-
// RUN: -parse-stdlib -module-name Swift
3-
4-
// NOTE: -parse-stdlib is a transitional workaround and should not be required.
1+
// RUN: %target-typecheck-verify-swift -disable-availability-checking
52

63
@_moveOnly // expected-error {{'@_moveOnly' attribute is only valid on structs or enums}}
74
class KlassLegacy {}
85

96
class KlassModern: ~Copyable {} // expected-error {{classes cannot be '~Copyable'}}
107

8+
actor FamousPerson: ~Copyable {} // expected-error{{actors cannot be '~Copyable'}}
9+
1110
class Konditional<T: ~Copyable> {}
1211

1312
func checks<T: ~Copyable, C>(

0 commit comments

Comments
 (0)