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-9845] Regression when referencing protocol initializer from protocol-composed type #52256

Closed
swift-ci opened this issue Feb 2, 2019 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.0 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 2, 2019

Previous ID SR-9845
Radar rdar://problem/47787705
Original Reporter luiz (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

macOS Mojave 10.14.2 (18C54)

Xcode 10.2 beta (10P82s)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, TypeChecker
Assignee luiz (JIRA)
Priority Medium

md5: cfe46c4dada7d74091fb90f0f8883a04

Issue Description:

The following snippet succeeds on Xcode 10.1, but fails on the latest Xcode 10.2 beta (10P82s):

protocol Foo {
    init(value: Int)
}

class Bar {
    init(value: Int, otherValue: String = "") {
        
    }
}

func makeFooBar<T: Foo & Bar>(type: T.Type) -> T {
    return T.init(value: 0) // error: Constructing an object of class type 'T' with a metatype value must use a 'required' initializer
}

My guess is that the type resolver picks the initializer with the default argument

Bar.init(value:otherValue:)

and ends up ignoring the protocol-defined initializer.

@xedin
Copy link
Member

xedin commented Feb 7, 2019

Thanks for the report luiz (JIRA User)! The problem should be fixed by #22379 Please use the next available snapshot of master compiler to verify and resolve.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 7, 2019

Comment by Luiz Fernando Silva (JIRA)

Will do! Thanks for the quick response on this one.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 9, 2019

luiz (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

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

No branches or pull requests

3 participants