Skip to content

[SR-7353] Invalid error and warning related to recursive constraints on associated type #49901

@jepers

Description

@jepers
Previous ID SR-7353
Radar rdar://problem/39225307
Original Reporter @jepers
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.3, default toolchain and eg dev snapshot 2018-03-28

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

md5: c26cdc0dbaf628a2e81a170395fe5d27

Issue Description:

Note that the following compiles as expected (in Xcode 9.3):

protocol P {
    associatedtype A: Q where A.B == Self
}
protocol Q {
    associatedtype B: P where B.A == Self
}

But adding a second associated type `C` to `Q` will produce the following invalid error and warning:

protocol P {
    associatedtype A: Q where A.B == Self
}
protocol Q {
    associatedtype B: P where B.A == Self
    associatedtype C: P where C.A == Self // Error and Warning
}
// Error: `A` is not a member of type `Self.C`
// Warning: Redundant conformance constraint 'Self.C': 'P'

BUT: The error goes away (but not the warning) if the protocol definitions are swapped, so that Q is defined before P. Also, there is no error when using eg dev snapshot 2018-03-28, no matter the order of P and Q.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions