Skip to content

Commit c73dff8

Browse files
Isolated keyword should not be permitted in inheritance clause
1 parent e293876 commit c73dff8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5391,10 +5391,10 @@ TypeResolver::resolveOwnershipTypeRepr(OwnershipTypeRepr *repr,
53915391
NeverNullType
53925392
TypeResolver::resolveIsolatedTypeRepr(IsolatedTypeRepr *repr,
53935393
TypeResolutionOptions options) {
5394-
// isolated is only value for non-EnumCaseDecl parameters.
5394+
// isolated is only valid for non-EnumCaseDecl parameters.
53955395
if ((!options.is(TypeResolverContext::FunctionInput) ||
5396-
options.hasBase(TypeResolverContext::EnumElementDecl)) &&
5397-
!options.is(TypeResolverContext::Inherited)) {
5396+
(options.hasBase(TypeResolverContext::EnumElementDecl) &&
5397+
!options.is(TypeResolverContext::Inherited)) || options.is(TypeResolverContext::Inherited))) {
53985398
diagnoseInvalid(
53995399
repr, repr->getSpecifierLoc(), diag::attr_only_on_parameters,
54005400
"isolated");

test/Concurrency/isolated_parameters.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,8 @@ struct WritableActorKeyPath<Root: Actor, Value>: Sendable {
343343
nonmutating set { setter(root, newValue) }
344344
}
345345
}
346+
347+
protocol P {}
348+
struct S: isolated P {} // expected-error {{'isolated' may only be used on parameters}}
349+
350+

0 commit comments

Comments
 (0)