-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Distributed] Only parse distributed when experimental mode enabled #38889
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1611,6 +1611,14 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc, | |
DiscardAttribute = true; | ||
} | ||
|
||
// If this attribute is only permitted when distributed is enabled, reject it. | ||
if (DeclAttribute::isDistributedOnly(DK) && | ||
!shouldParseExperimentalDistributed()) { | ||
diagnose(Loc, diag::attr_requires_distributed, AttrName, | ||
DeclAttribute::isDeclModifier(DK)); | ||
DiscardAttribute = true; | ||
} | ||
|
||
Comment on lines
+1614
to
+1621
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this is the only thing that's actually needed to solve the issue. Everything else is just for availability things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove the availability support from this PR, thanks |
||
if (Context.LangOpts.Target.isOSBinFormatCOFF()) { | ||
if (DK == DAK_WeakLinked) { | ||
diagnose(Loc, diag::attr_unsupported_on_target, AttrName, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-distributed | ||
// REQUIRES: concurrency | ||
// REQUIRES: distributed | ||
|
||
actor SomeActor {} | ||
|
||
@available(SwiftStdlib 5.5, *) | ||
distributed actor DA {} | ||
// expected-error@-1{{'_Distributed' module not imported, required for 'distributed actor'}} | ||
|
||
@available(SwiftStdlib 5.5, *) | ||
distributed actor class DAC {} | ||
// expected-error@-1{{distributed' can only be applied to 'actor' definitions, and distributed actor-isolated async functions}} | ||
// expected-error@-2{{keyword 'class' cannot be used as an identifier here}} | ||
|
||
actor A { | ||
func normal() async {} | ||
distributed func dist() {} // expected-error{{'distributed' function can only be declared within 'distributed actor'}} | ||
distributed func distAsync() async {} // expected-error{{'distributed' function can only be declared within 'distributed actor'}} | ||
|
||
distributed var neverOk: String { // expected-error{{'distributed' modifier cannot be applied to this declaration}} | ||
"vars are not allowed to be distributed *ever* anyway" | ||
} | ||
} | ||
|
||
@available(SwiftStdlib 5.5, *) | ||
distributed actor DA2 { | ||
// expected-error@-1{{'_Distributed' module not imported, required for 'distributed actor'}} | ||
func normal() async {} | ||
distributed func dist() {} | ||
distributed func distAsync() async {} | ||
|
||
distributed var neverOk: String { // expected-error{{'distributed' modifier cannot be applied to this declaration}} | ||
"vars are not allowed to be distributed *ever* anyway" | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// RUN: %target-typecheck-verify-swift -disable-availability-checking | ||
// ^^^^ notice the, on purpose, missing '-enable-experimental-distributed' | ||
// REQUIRES: concurrency | ||
// REQUIRES: distributed | ||
|
||
import _Distributed | ||
|
||
@available(macOS 12.0, *) | ||
distributed actor A {} | ||
// expected-error@-1{{'distributed' modifier is only valid when experimental distributed support is enabled}} |
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.
I thought the module is called
Distributed
right now, with no underscore. The underscore is for implicitly-imported modules I think.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.
The import is
_Distributed
, same as _Concurrency was and it did have to be imported explicitly for a while.