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-5371] Allow subclass have throwing initializer when superclass don't #47945

Closed
swift-ci opened this issue Jul 5, 2017 · 1 comment
Closed
Labels
compiler The Swift compiler in itself improvement

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jul 5, 2017

Previous ID SR-5371
Radar None
Original Reporter yzwang (JIRA User)
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: 0010323682cb4e9a5b71c8fd9fbc23d2

duplicates:

  • SR-5355 "Cannot override non-throwing initializer with throwing initializer"

Issue Description:

class Foo {
    init() {}
}

class Bar: Foo {
    override init() throws {
        //if something goes wrong, throw error
        super.init()
    }
}

which produce "Cannot override non-throwing initializer with throwing initializer"


I can workaround this by

class Foo {
    init() {}
}

class Bar: Foo {
    init(_ comeOn: Int? = nil) throws {
        //if something goes wrong, throw error
        super.init()
    }
}
@belkadan
Copy link
Contributor

belkadan commented Jul 5, 2017

This is really exactly the same as SR-5355. We don't need two bugs for it.

@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
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

2 participants