[swift-users] Initializer inheritance doesn't work with generic class?

Neil Faiman neil.swift at faiman.org
Sun May 15 16:41:37 CDT 2016


Here is another, more blatant example of the failure to inherit initializers from a generic base class:

    class Concrete {
        init(value: Int) {}
    }

    class ConcreteSub : Concrete {
    }

    class Generic<T> {
        init(value: T) {}
    }

    class GenericSub : Generic<Int> {
    }

    let concrete = ConcreteSub(value: 1)
    let generic = GenericSub(value: 1)

error: 'GenericSub' cannot be constructed because it has no accessible initializers
    let generic = GenericSub(value: 1)
                  ^



More information about the swift-users mailing list