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-416] Automatic initializer inheritance doesn't work for generic types. #43033

Closed
swift-ci opened this issue Dec 30, 2015 · 2 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-416
Radar rdar://problem/17960407
Original Reporter AntiMoron (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 8
Component/s Compiler
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 653f63eac7d43989c4cea17dfc9d61f0

is duplicated by:

  • SR-1375 Availability of default values in initializer or generics in class definition may prevent swift from inheritance of initializer.
  • SR-924 Subclass of generic class has no initializers

Issue Description:

For such code:

public class A<T : Any> { 
    public init(n : Int) { 
        print("A")
    } 
} 
public class B : A<Int> {
}
let x = B(n: 123)

The two rules from documation have no effect.

Rule 1 “If your subclass doesn’t define any designated initializers, it automatically inherits all of its superclass designated initializers.”
Rule 2 “If your subclass provides an implementation of all of its superclass designated initializers—either by inheriting them as per rule 1, or by providing a custom implementation as part of its definition—then it automatically inherits all of the superclass convenience initializers.”

For more details see http://stackoverflow.com/questions/34525368/initializers-from-generic-types-wont-be-inherited-in-swift

@swift-ci
Copy link
Contributor Author

swift-ci commented May 2, 2016

Comment by Nikita Leonov (JIRA)

https://bugs.swift.org/browse/SR-1375 has some interesting observation regarding current behavior. Apparently default values in init preventing an initializer to be inherit in case of generic classes.

@slavapestov
Copy link
Contributor

Fixed in master.

@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 itself
Projects
None yet
Development

No branches or pull requests

2 participants