Four classes, first two normal, Two inherits from One, Two inherits One's initializers as expected.
Second two are generic, Four<T> inherits from Three<T>, but everything else is the same. However Four doesn't inherit Three's initializer.
Is that a bug or have I missed yet something else in the Swift book?
public class One
{
public var value : Int
public init( value : Int )
{
self.value = value
}
}
public class Two : One
{
public func foo()
{
print( "value is \(value)" )
}
}
public class Three<T>
{
public var value : T
public init( value : T )
{
self.value = value
}
}
public class Four<T> : Three<T>
{
public func foo()
{
print( "value is \(value)" )
}
}
let x = Two( value : 123 ) // *** WORKS ****, Two inherits One's init(value:) method
x.foo()
let y = Four<Int>( value : 123 ) // Four<Int>' cannot be constructed because it has no accessible initializers
y.foo()