swift icon indicating copy to clipboard operation
swift copied to clipboard

[SR-2484] Bad diagnostic for incorrectly calling private init

Open jadengeller opened this issue 10 years ago • 9 comments

Previous ID SR-2484
Radar None
Original Reporter @jadengeller
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 3, beta 6

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI
Assignee @jadengeller
Priority Medium

md5: 48481479ceefe5c851145b6a83845eec

relates to:

  • SR-3236 Bogus diagnostics for referencing ".init" on instances

Issue Description:

"`super.init` cannot be called outside the initializer", in the initializer

class Object {
    private init() {

    }
}

class Foo: Object {
    init() {
        super.init()
    }
}

jadengeller avatar Aug 25 '16 18:08 jadengeller

The override doesn't actually change anything. private is private either way.

belkadan avatar Aug 25 '16 18:08 belkadan

Yes, but you get the correct diagnostic once marked `override`.

jadengeller avatar Aug 25 '16 19:08 jadengeller

Hm, I don't (with master).

belkadan avatar Aug 25 '16 19:08 belkadan

I guess it was fixed then? The attached screenshot shows the diagnostic in the latest beta.

jadengeller avatar Aug 25 '16 19:08 jadengeller

No, I mean I get the bad diagnostic in both cases.

belkadan avatar Aug 25 '16 19:08 belkadan

Oh, it does look like that's true. At least in that case you also get another diagnostic so yo know things are broken. Without override, a user might be very confused (especially since the behavior of `private` changed).

jadengeller avatar Aug 25 '16 19:08 jadengeller

There's a PR for this under view: https://github.com/apple/swift/pull/5237

rudkx avatar Oct 14 '16 07:10 rudkx

Please verify with a build that includes the fix and then close if you agree the issue is fixed. Re-open if the issue is not fixed, or open a new ticket if you find a new issue.

rudkx avatar Oct 18 '16 04:10 rudkx