Skip to content

[SR-14917] Inconsistent/missing warning about redundant same-type constraint #57264

@jepers

Description

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

macOS 11.3, Xcode 12.5 and 12.5.1

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

md5: 5107e4b57e6a7f5c8dd5e4d6703b74f3

Issue Description:

This compiles with the expected warning:

struct S<T: Collection> where T.Index == T.Indices.Index {} // Warning: Redundant same-type constraint `T.Index` == `T.Indices.Index`

But this compiles without any warning:

extension Collection where Self.Index == Self.Indices.Index {} // No warning

I would have expected the same warning here.

This inconsistent behaviour is reproduced by eg:

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

protocol Q {
  associatedtype B
}

struct S<T: P> where T.AS.B == T.A {} // Warning as expected

extension P where AS.B == A {} // No warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions