You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.”
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.
Additional Detail from JIRA
md5: 653f63eac7d43989c4cea17dfc9d61f0
is duplicated by:
Issue Description:
For such code:
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
The text was updated successfully, but these errors were encountered: