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-14003] Bad diagnostic when assigning a closure with class Self #56396

Closed
amomchilov opened this issue Dec 29, 2020 · 1 comment
Closed

[SR-14003] Bad diagnostic when assigning a closure with class Self #56396

amomchilov opened this issue Dec 29, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@amomchilov
Copy link
Contributor

Previous ID SR-14003
Radar None
Original Reporter @amomchilov
Type Bug
Status Resolved
Resolution Done
Environment
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin20.1.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: e280acd42d8cfa2b19e7fca2189f5048

Issue Description:

class C {
    var callback: ((C) -> Void)!
    
    func setCallback(_ callback: @escaping (Self) -> Void) {
        self.callback = callback // Cannot assign to property: 'self' is immutable
    }
}

From what I can tell, this assignment should be disallowed (since for any potential subclass, Self will differ from C), unless C is made final (should that be a separate bug)?

In any case, this diagnostic message is incorrect, though I'm not sure what the wording should be.

Is there a term for the process of taking a Self and converting it to a place where the literal type name is used?

@LucianoPAlmeida
Copy link
Collaborator

Resolved by #35247
@amomchilov Can you please verify on the next available snapshot and close? Thanks

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants