Skip to content
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

@preconcurrency on a function typealias has no effect #60487

Closed
dnadoba opened this issue Aug 10, 2022 · 0 comments · Fixed by #60537
Closed

@preconcurrency on a function typealias has no effect #60487

dnadoba opened this issue Aug 10, 2022 · 0 comments · Fixed by #60537
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@dnadoba
Copy link
Member

dnadoba commented Aug 10, 2022

Describe the bug
@preconcurrency on a function typealias has no effect. It should either have an effect as to would on a method taking a function or produce a diagnostics that it is not supported.

Steps To Reproduce

@preconcurrency typealias Callback = @Sendable () -> ()
func methodWithPreconcurrencyOnTypealias(callback: Callback) {}
@preconcurrency func methodWithPreconcurrencyOnMethod(callback: @Sendable () -> ()) {}

func usage() {
    var mutableVariable = 0
    methodWithPreconcurrencyOnTypealias {
        mutableVariable += 1 // sendable warning
    }
    
    methodWithPreconcurrencyOnMethod {
        mutableVariable += 1 // no sendable warning
    }
}

Expected behavior
It would be best if we wouldn't get a warning and methodWithPreconcurrencyOnTypealias(callback:) would be treated the same as methodWithPreconcurrencyOnMethod(callback:).
However, typealias is no listed in SE-0337 as a a nominal declaration where the @preconcurrency attribute can be used and therefore should at least produce some diagnostics.

Screenshots
Screenshot 2022-08-10 at 13 31 52

Environment (please fill out the following information)

  • OS: 13.0 Beta (22A5311f)
  • Xcode: Version 14.0 beta 5 (14A5294e)
@dnadoba dnadoba added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Aug 10, 2022
DougGregor added a commit to DougGregor/swift that referenced this issue Aug 12, 2022
…use.

When referencing a `@preconcurrency` typealias from code that does not
require strict concurrency, strip off `@Sendable` and global actor
types. This is consistent with references to functions/properties/etc.
that are `@preconcurrency`.

Fixes apple#60487, rdar://98343624.
DougGregor added a commit to DougGregor/swift that referenced this issue Aug 17, 2022
…use.

When referencing a `@preconcurrency` typealias from code that does not
require strict concurrency, strip off `@Sendable` and global actor
types. This is consistent with references to functions/properties/etc.
that are `@preconcurrency`.

Fixes apple#60487, rdar://98343624.
DougGregor added a commit that referenced this issue Aug 17, 2022
…use.

When referencing a `@preconcurrency` typealias from code that does not
require strict concurrency, strip off `@Sendable` and global actor
types. This is consistent with references to functions/properties/etc.
that are `@preconcurrency`.

Fixes #60487, rdar://98343624.
DougGregor added a commit to DougGregor/swift that referenced this issue Aug 17, 2022
…use.

When referencing a `@preconcurrency` typealias from code that does not
require strict concurrency, strip off `@Sendable` and global actor
types. This is consistent with references to functions/properties/etc.
that are `@preconcurrency`.

Fixes apple#60487, rdar://98343624.

(cherry picked from commit 5b88b96)
meg-gupta pushed a commit to meg-gupta/swift that referenced this issue Aug 18, 2022
…use.

When referencing a `@preconcurrency` typealias from code that does not
require strict concurrency, strip off `@Sendable` and global actor
types. This is consistent with references to functions/properties/etc.
that are `@preconcurrency`.

Fixes apple#60487, rdar://98343624.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant