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

[SR-15448] Cannot use Self as function parameter type in actors #57753

Open
WowbaggersLiquidLunch opened this issue Nov 5, 2021 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@WowbaggersLiquidLunch
Copy link
Collaborator

Previous ID SR-15448
Radar None
Original Reporter @WowbaggersLiquidLunch
Type Bug
Environment

macOS 12.0.1 (21A558)

2021-10-27 development toolchain

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 53142994a90b8134469f7159831a33e4

relates to:

  • SR-11176 Covariant 'Self' type cannot be referenced from a stored property initializer

Issue Description:

actor Foo {
    init(bar: Int) { ... }
    let bar: Int
    
    // error: Covariant 'Self' or 'Self?' can only appear as the type of a property, subscript or method result; did you mean 'Foo'?
    // fix-it: Replace 'Self' with 'Foo'
    func printFoo(foo: Self) {
        print(foo.bar)
    }
}

extension Foo: Equatable {
    // error: Covariant 'Self' or 'Self?' can only appear as the type of a property, subscript or method result; did you mean 'Foo'?
    // fix-it: Replace 'Self' with 'Foo'
    static func == (lhs: Self, rhs: Self) -> Bool {
        lhs.bar == rhs.bar
    }
}

It should be legal to use Self as function parameter type in actors, in my opinion.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

1 participant