Skip to content

Commit

Permalink
fix diagnostic messages that said '@actorIsolated' for @actorIndependent
Browse files Browse the repository at this point in the history
  • Loading branch information
kavon committed Oct 19, 2020
1 parent 68b790f commit 849e9d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions include/swift/AST/DiagnosticsSema.def
Expand Up @@ -4207,22 +4207,22 @@ ERROR(global_actor_isolated_requirement_witness_conflict,none,
"requirement from protocol %3 isolated to global actor %4",
(DescriptiveDeclKind, DeclName, Type, Identifier, Type))

ERROR(actorisolated_let,none,
"'@actorIsolated' is meaningless on 'let' declarations because "
ERROR(actorindependent_let,none,
"'@actorIndependent' is meaningless on 'let' declarations because "
"they are immutable",
())
ERROR(actorisolated_mutable_storage,none,
"'@actorIsolated' can not be applied to stored properties",
ERROR(actorindependent_mutable_storage,none,
"'@actorIndependent' can not be applied to stored properties",
())
ERROR(actorisolated_local_var,none,
"'@actorIsolated' can not be applied to local variables",
ERROR(actorindependent_local_var,none,
"'@actorIndependent' can not be applied to local variables",
())
ERROR(actorisolated_not_actor_member,none,
"'@actorIsolated' can only be applied to actor members and "
ERROR(actorindependent_not_actor_member,none,
"'@actorIndependent' can only be applied to actor members and "
"global/static variables",
())
ERROR(actorisolated_not_actor_instance_member,none,
"'@actorIsolated' can only be applied to instance members of actors",
ERROR(actorindependent_not_actor_instance_member,none,
"'@actorIndependent' can only be applied to instance members of actors",
())

ERROR(concurrency_lib_missing,none,
Expand Down
10 changes: 5 additions & 5 deletions lib/Sema/TypeCheckAttr.cpp
Expand Up @@ -286,19 +286,19 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
if (auto var = dyn_cast<VarDecl>(D)) {
// @actorIndependent is meaningless on a `let`.
if (var->isLet()) {
diagnoseAndRemoveAttr(attr, diag::actorisolated_let);
diagnoseAndRemoveAttr(attr, diag::actorindependent_let);
return;
}

// @actorIndependent can not be applied to stored properties.
if (var->hasStorage()) {
diagnoseAndRemoveAttr(attr, diag::actorisolated_mutable_storage);
diagnoseAndRemoveAttr(attr, diag::actorindependent_mutable_storage);
return;
}

// @actorIndependent can not be applied to local properties.
if (dc->isLocalContext()) {
diagnoseAndRemoveAttr(attr, diag::actorisolated_local_var);
diagnoseAndRemoveAttr(attr, diag::actorindependent_local_var);
return;
}

Expand All @@ -315,14 +315,14 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
// @actorIndependent only makes sense on an actor instance member.
if (!dc->getSelfClassDecl() ||
!dc->getSelfClassDecl()->isActor()) {
diagnoseAndRemoveAttr(attr, diag::actorisolated_not_actor_member);
diagnoseAndRemoveAttr(attr, diag::actorindependent_not_actor_member);
return;
}

auto VD = cast<ValueDecl>(D);
if (!VD->isInstanceMember()) {
diagnoseAndRemoveAttr(
attr, diag::actorisolated_not_actor_instance_member);
attr, diag::actorindependent_not_actor_instance_member);
return;
}

Expand Down
12 changes: 6 additions & 6 deletions test/attr/actorindependent.swift
@@ -1,6 +1,6 @@
// RUN: %target-swift-frontend -typecheck -verify %s -enable-experimental-concurrency

// expected-error@+1{{'@actorIsolated' can only be applied to actor members and global/static variables}}
// expected-error@+1{{'@actorIndependent' can only be applied to actor members and global/static variables}}
@actorIndependent func globalFunction() { }

@actorIndependent var globalComputedProperty1: Int { 17 }
Expand All @@ -10,7 +10,7 @@
set { }
}

// expected-error@+1{{'@actorIsolated' can not be applied to stored properties}}
// expected-error@+1{{'@actorIndependent' can not be applied to stored properties}}
@actorIndependent var globalStoredProperty: Int = 17

struct X {
Expand All @@ -25,21 +25,21 @@ struct X {
set { }
}

// expected-error@+1{{'@actorIsolated' can not be applied to stored properties}}
// expected-error@+1{{'@actorIndependent' can not be applied to stored properties}}
@actorIndependent
static var storedStaticProperty: Int = 17
}

class C {
// expected-error@+1{{'@actorIsolated' can only be applied to actor members and global/static variables}}
// expected-error@+1{{'@actorIndependent' can only be applied to actor members and global/static variables}}
@actorIndependent
var property3: Int { 5 }
}

actor class A {
var property: Int = 5

// expected-error@+1{{'@actorIsolated' can not be applied to stored properties}}
// expected-error@+1{{'@actorIndependent' can not be applied to stored properties}}
@actorIndependent
var property2: Int = 5

Expand Down Expand Up @@ -72,6 +72,6 @@ actor class A {
@actorIndependent
subscript(index: Int) -> String { "\(index)" }

// expected-error@+1{{'@actorIsolated' can only be applied to instance members of actors}}
// expected-error@+1{{'@actorIndependent' can only be applied to instance members of actors}}
@actorIndependent static func staticFunc() { }
}

0 comments on commit 849e9d6

Please sign in to comment.