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-11886] Incorrect associated type inference when default implementation uses concrete type instead of associated type name #54302

Open
swift-ci opened this issue Dec 2, 2019 · 1 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

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 2, 2019

Previous ID SR-11886
Radar rdar://problem/57711757
Original Reporter Anandabits (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: a51f991b90c09b14901c71e6664191c4

Issue Description:

This code fails to compile in Xcode 10.3 and 11.2.1.

protocol P {
    associatedtype A: PA = Never where A.VA == B.A
    associatedtype B: PB
}

protocol PA {
    associatedtype VA = Self
    init(va: VA)
}
extension PA where VA == Self {
    init(va: VA) {
        self = va
    }
}
extension PA where VA == Never {
// note: when this is spelled
// init(va: VA) {
// the error does not occur
    init(va: Never) {
        switch va {}
    }
}
extension Never: PA {
    init(va: Never) {
        switch va {}
    }
}

protocol PB {
    associatedtype A = Void
}

struct S: P { // ERROR: 'P' requires the types 'Never' and 'SB.A' be equivalent
    typealias B = SB
    typealias A = B.A
}

struct SB: PB {
    enum A: PA {}
}
@beccadax
Copy link
Contributor

beccadax commented Dec 6, 2019

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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