Skip to content

Warning about same-type requirement making generic params equivalent should extend to nested type parameters #63354

Open
@AnthonyLatsis

Description

@AnthonyLatsis

The compiler emits a warning on a same-type constraint between generic parameter types:

// warning: same-type requirement makes generic parameters 'U' and 'T' equivalent; this is an error in Swift 6
func foo1<T, U>(_: T, _: U) where U == T {}

I believe a similar warning is then warranted if a generic parameter is equated to a nested type parameter:

protocol P {
 associatedtype A
}

func foo2<T: P, U>(_: T, _: U) where U == T.A {}

Possible warning: same-type requirement makes generic parameter 'U' redundant; this is an error in Swift 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationgeneric constraintsFeature → generics: generic constraintsgenericsFeature: generic declarations and typesimprovementmissing warningBug: Missing warningswift 5.9type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions