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-2813] Required failable initializer is not recognized on NSManagedObject #45417

Closed
swift-ci opened this issue Oct 1, 2016 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 1, 2016

Previous ID SR-2813
Radar None
Original Reporter christosc (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 8, Swift 3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 68f6b50b404ce1512b55f770c0ef6ded

duplicates:

  • SR-1663 Cannot invoke initializers required by protocols on associated types with non-root-class superclass bounds

Issue Description:

The following code fails to compile:

import Foundation
import CoreData

protocol P {
    init?(i: Int)
}


class C {
    func f<T: NSObject>(i: Int) -> T? where T: P {
        return T(i: i)  // compiles OK
    }
    
    func g<T: NSManagedObject>(i: Int) -> T? where T: P {
        return T(i: i)  // doesn't compile: "Incorrect argument label in call
                        // (have: 'i:', expected 'context:')
    }
}

Shouldn't the behavior for the NSManagedObject class be the same as for NSObject?

@belkadan
Copy link
Contributor

belkadan commented Oct 3, 2016

Maybe we're just not even adding it to the overload set. @DougGregor, @rudkx?

@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 in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants