swift-book icon indicating copy to clipboard operation
swift-book copied to clipboard

Requirement inference is not documented

Open slavapestov opened this issue 2 years ago • 0 comments

Location

No response

Description

This code type checks and infers T: Hashable:

func foo<T>(_: Set<T>) {}

A more complex example; we infer T.Element: Hashable:

func foo<T: Sequence>(_: T) -> Set<Array<T.Element>> {}

I couldn't find mention of this behavior anywhere in TSPL.

Motivation

No response

Alternatives Considered

No response

slavapestov avatar Apr 24 '23 21:04 slavapestov