Skip to content

[SR-9595] Unexpected error when type checking constrained associated types #52042

@rxwei

Description

@rxwei
Previous ID SR-9595
Radar rdar://problem/75329340
Original Reporter @rxwei
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee @slavapestov
Priority Medium

md5: 566220f9d77423bbecc919b4912e7ab1

relates to:

  • TF-213 [AD] Fix Differentiable protocol generic signature bug

Issue Description:

I expect the following to compile:

protocol Q {
  associatedtype Assoc
}

protocol P {
  associatedtype T : P, Q where T.Assoc : FloatingPoint, T == U.U
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
}

... but the compiler produces a ton of warnings that don't really make sense.

sr9595.swift:6:22: warning: redundant conformance constraint 'Self.T': 'P'
  associatedtype T : P, Q where T.Assoc : FloatingPoint, T == U.U
                     ^
sr9595.swift:7:22: note: conformance constraint 'Self.T.T': 'P' implied here
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                     ^
sr9595.swift:6:25: warning: redundant conformance constraint 'Self.T': 'Q'
  associatedtype T : P, Q where T.Assoc : FloatingPoint, T == U.U
                        ^
sr9595.swift:7:22: note: conformance constraint 'Self.T.T': 'Q' implied here
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                     ^
sr9595.swift:6:41: warning: redundant conformance constraint 'Self.T.Assoc': 'FloatingPoint'
  associatedtype T : P, Q where T.Assoc : FloatingPoint, T == U.U
                                        ^
sr9595.swift:7:22: note: conformance constraint 'Self.T.T.Assoc': 'FloatingPoint' implied here
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                     ^
sr9595.swift:7:25: warning: redundant conformance constraint 'Self.U': 'Q'
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                        ^
sr9595.swift:7:22: note: conformance constraint 'Self.U': 'Q' implied here
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                     ^
sr9595.swift:7:41: warning: redundant conformance constraint 'Self.U.Assoc': 'FloatingPoint'
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                                        ^
sr9595.swift:7:22: note: conformance constraint 'Self.U.Assoc': 'FloatingPoint' implied here
  associatedtype U : P, Q where U.Assoc : FloatingPoint, U == T.U
                     ^

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselftype checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions