Files
swift-mirror/test/Constraints/sr13992.swift
Pavel Yaskevich f0ff68e707 [Diagnostics] Special case requirement failures related to return statement/expression
Make sure that "affected" declaration is recognized as the one
to which result type is attached to if the requirement failure
is originated in contextual type of `return` statement/expression.

Resolves: SR-13992
Resolves: rdar://72819046
Resolves: rdar://57789606
2021-01-06 12:47:37 -08:00

30 lines
582 B
Swift

// RUN: %target-typecheck-verify-swift
// SR-13992
protocol V {}
protocol P1 {}
protocol P2 {
func bar() -> V
}
protocol P3 {}
struct S<T> {
var foo: T
}
extension S : P1 {}
extension S : P2 where T: P3 { // expected-note {{requirement from conditional conformance of 'S<V>' to 'P2'}}
func bar() -> V { fatalError() }
}
struct Q {
var foo: V
func test() -> P1 & P2 {
S(foo: foo) // expected-error {{protocol 'V' as a type cannot conform to 'P3'}}
// expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
}
}