-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema]Skip Sendable conformance check when sending
are added to parameters or return types of an actor-isolated function
#78601
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
test/Concurrency/sendable_conformance_checking_skip_sending.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// RUN: %target-typecheck-verify-swift -swift-version 6 | ||
|
||
// https://github.com/swiftlang/swift/issues/76710 | ||
|
||
class NonSendableKlass1 {} | ||
|
||
protocol P1 { | ||
func bar(_ a: sending NonSendableKlass1) async -> sending NonSendableKlass1 | ||
} | ||
|
||
@MainActor | ||
class P1Class: P1 { | ||
func bar(_ a: sending NonSendableKlass1) async -> sending NonSendableKlass1 { a } | ||
} | ||
|
||
class NonSendableKlass2 {} | ||
// expected-note@-1 2{{class 'NonSendableKlass2' does not conform to the 'Sendable' protocol}} | ||
|
||
protocol P2 { | ||
func bar(_ a: NonSendableKlass2) async -> NonSendableKlass2 | ||
} | ||
|
||
@MainActor | ||
class P2Class: P2 { | ||
func bar(_ a: NonSendableKlass2) async -> NonSendableKlass2 { a } | ||
// expected-error@-1 {{non-sendable type 'NonSendableKlass2' cannot be returned from main actor-isolated implementation to caller of protocol requirement 'bar'}} | ||
// expected-error@-2 {{non-sendable parameter type 'NonSendableKlass2' cannot be sent from caller of protocol requirement 'bar' into main actor-isolated implementation}} | ||
} | ||
|
||
class NonSendableKlass3 {} | ||
|
||
protocol P3 { | ||
func bar(_ a: sending NonSendableKlass3) async -> sending NonSendableKlass3 | ||
} | ||
|
||
actor P3Actor: P3 { | ||
func bar(_ a: sending NonSendableKlass3) async -> sending NonSendableKlass3 { NonSendableKlass3() } | ||
} | ||
|
||
class NonSendableKlass4 {} | ||
// expected-note@-1 2{{class 'NonSendableKlass4' does not conform to the 'Sendable' protocol}} | ||
|
||
protocol P4 { | ||
func bar(_ a: NonSendableKlass4) async -> NonSendableKlass4 | ||
} | ||
|
||
actor P4Actor: P4 { | ||
func bar(_ a: NonSendableKlass4) async -> NonSendableKlass4 { NonSendableKlass4() } | ||
// expected-error@-1 {{non-sendable type 'NonSendableKlass4' cannot be returned from actor-isolated implementation to caller of protocol requirement 'bar'}} | ||
// expected-error@-2 {{non-sendable parameter type 'NonSendableKlass4' cannot be sent from caller of protocol requirement 'bar' into actor-isolated implementation}} | ||
} | ||
|
||
class NonSendableKlass5 {} | ||
// expected-note@-1 {{class 'NonSendableKlass5' does not conform to the 'Sendable' protocol}} | ||
|
||
|
||
protocol P5 { | ||
func bar(_ a: sending NonSendableKlass5, _ b: NonSendableKlass5) async -> sending NonSendableKlass5 | ||
} | ||
|
||
@MainActor | ||
class P5Class: P5 { | ||
func bar(_ a: sending NonSendableKlass5, _ b: NonSendableKlass5) async -> sending NonSendableKlass5 { a } | ||
// expected-error@-1 {{non-sendable parameter type 'NonSendableKlass5' cannot be sent from caller of protocol requirement 'bar' into main actor-isolated implementation}} | ||
} | ||
|
||
class NonSendableKlass6 {} | ||
|
||
protocol P6 { | ||
func bar(_ a: sending NonSendableKlass6, _ b: sending NonSendableKlass6) async -> sending NonSendableKlass6 | ||
} | ||
|
||
@MainActor | ||
class P6Class: P6 { | ||
func bar(_ a: sending NonSendableKlass6, _ b: sending NonSendableKlass6) async -> sending NonSendableKlass6 { a } | ||
} | ||
|
||
class NonSendableKlass7 {} | ||
|
||
protocol P7 { | ||
subscript(_: sending NonSendableKlass7) -> sending NonSendableKlass7 { get async } | ||
} | ||
|
||
@MainActor | ||
struct S: P7 { | ||
subscript(_: sending NonSendableKlass7) -> sending NonSendableKlass7 { | ||
get async { NonSendableKlass7() } | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 can simplify this down to
isa_and_nonnull<SendingTypeRepr>(subscript->getResultTypeRepr())
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.
@xedin
Thank you! I fixed it.
55e8d55