-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change 'actor class' to 'actor' #35794
Change 'actor class' to 'actor' #35794
Conversation
|
||
class NonActor { } | ||
|
||
actor class NonActorSubclass : NonActor { } // expected-error{{actor class cannot inherit from non-actor class 'NonActor'}} | ||
actor NonActorSubclass : NonActor { } // expected-error{{actor class cannot inherit from non-actor class 'NonActor'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we instead be calling them "actor" rather than actor class in all diagnostics from here on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that seems like a good idea.
ad4664d
to
4487f9c
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great; just two trivial comments that shouldn't block you from merging.
lib/Parse/ParseDecl.cpp
Outdated
@@ -4148,6 +4206,13 @@ Parser::parseDecl(ParseDeclOptions Flags, | |||
// Obvious nonsense. | |||
default: | |||
|
|||
if (shouldParseExperimentalConcurrency() && Tok.is(tok::identifier) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the Tok.is(too::identifier)
here, because it's part of Tok.isContextualKeyword
.
include/swift/AST/Decl.h
Outdated
@@ -3587,7 +3590,8 @@ class ClassDecl final : public NominalTypeDecl { | |||
public: | |||
ClassDecl(SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc, | |||
ArrayRef<TypeLoc> Inherited, | |||
GenericParamList *GenericParams, DeclContext *DC); | |||
GenericParamList *GenericParams, DeclContext *DC, | |||
bool isActor=false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth dropping the default argument so we don't forget to pass it somewhere in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping it got a little nastier than intended. The unit tests have a makeNominal
that will construct something based on a template argument. That thing is either a ClassDecl
or a StructDecl
.
Ended up with this little specialization of makeNominal
. Not great, but not terrible.
template <typename Nominal>
Nominal *makeNominal(StringRef name,
GenericParamList *genericParams = nullptr) {
auto result = new (Ctx) Nominal(SourceLoc(), Ctx.getIdentifier(name),
SourceLoc(), /*inherited*/{},
genericParams, FileForLookups);
result->setAccess(AccessLevel::Internal);
return result;
}
template <>
swift::ClassDecl *makeNominal(StringRef name,
GenericParamList *genericParams) {
auto result = new (Ctx) ClassDecl(SourceLoc(), Ctx.getIdentifier(name),
SourceLoc(), /*inherited*/{},
genericParams, FileForLookups,
/*isActor*/false);
result->setAccess(AccessLevel::Internal);
return result;
}
c611913
to
67cd3ad
Compare
@swift-ci please test |
Build failed |
Build failed |
Heh, there were more places where constructed ClassDecls. :) I think I have all of them fixed, just testing locally. |
67cd3ad
to
d34e546
Compare
@swift-ci please test |
d34e546
to
ecf7b81
Compare
@swift-ci please test |
Build failed |
ecf7b81
to
1fcc706
Compare
@swift-ci please test |
Build failed |
Build failed |
1fcc706
to
15ca7a4
Compare
@swift-ci please test |
15ca7a4
to
a9ab561
Compare
@swift-ci please smoke test |
Build failed |
This patch softly updates the spelling of actors from `actor class` to `actor`. We still accept using `actor` as a modifying attribute of class, but emit a warning and fix-it to make the change. One of the challenges that makes this messier is that the modifier list can be in any order. e.g, `public actor class Foo {}` is the same as `actor public class Foo {}`. Classes have been updated to include whether they were explicitly declared as an actor. This change updates the swiftmodule serialization version number to 0.591. The additional bit only gets set of the class declaration was declared as an actor, not if the actor was applied as an attribute. This allows us to correctly emit `actor class` vs `actor` emitting the code back out.
This patch updates the once instance of actor class in the concurrency library to actor. This is the actor for the MainActor global actor.
This patch updates the `actor class` spelling to `actor` in almost all of the tests. There are places where I verify that we sanely handle `actor` as an attribute though. These include: - test/decl/class/actor/basic.swift - test/decl/protocol/special/Actor.swift - test/SourceKit/CursorInfo/cursor_info_concurrency.swift - test/attr/attr_objc_async.swift - test/ModuleInterface/actor_protocol.swift
a9ab561
to
8b80331
Compare
@swift-ci please smoke test |
We've decided to go with calling actor classes
actor
instead ofactor class
.We still want to be able to parse in
actor class
and recommend the correct fix-its to make it justactor
. This is a little challenging since we parse other modifiers in any order, soactor public class Foo
andpublic actor class Foo
were both totally parsable. We still need to be able to do that, which makes this change less pleasant.Furthermore, we want to make it a contextual keyword instead of an actual keyword so that we avoid breaking as much source. This also adds to the complexity.
I will update the diagnostics to refer to
actor
later.Resolves: rdar://73728503