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-924] Subclass of generic class has no initializers #43536

Closed
BigZaphod opened this issue Mar 11, 2016 · 1 comment
Closed

[SR-924] Subclass of generic class has no initializers #43536

BigZaphod opened this issue Mar 11, 2016 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@BigZaphod
Copy link

Previous ID SR-924
Radar None
Original Reporter @BigZaphod
Type Bug
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @slavapestov
Priority Medium

md5: a4b2afb1194a068582b854c6e493f8e4

duplicates:

  • SR-416 Automatic initializer inheritance doesn't work for generic types.

Issue Description:

The following code that inherits from a generic class generates the error "'TestSubclass' cannot be constructed because it has no accessible initializers" on the marked line.

class ValueClass<ValueType> {
    init(_ initialValue: ValueType) {
        value = initialValue
    }

    var value: ValueType
}

class TestSubclass: ValueClass<Int> {}

func tempFunc() {
    let tmp = TestSubclass(42)  // error here
}

However the following non-generic version works the way I expect:

class Something {
    init(_ initialValue: Int) {
        value = initialValue
    }
    
    var value: Int
}

class SomethingSubclass: Something {}

func tempSomething() {
    let tmp = SomethingSubclass(42)
}
@BigZaphod
Copy link
Author

I know this is super old, but I'm just confirming it was fixed at some point and closing 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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant