// RUN: %target-typecheck-verify-swift -disable-availability-checking protocol P { associatedtype A func f() -> A } func f1(x: any P) -> any P { // FIXME: Bad diagnostic return x // expected-error {{type of expression is ambiguous without a type annotation}} } func f2(x: any P) -> any P { return x // okay } func f3(x: any P) -> any P { // FIXME: Misleading diagnostic return x // expected-error {{cannot convert return expression of type 'Int' to return type 'String'}} } struct G {} // expected-note@-1 {{arguments to generic parameter 'T' ('any P' and 'any P') are expected to be equal}} // expected-note@-2 {{arguments to generic parameter 'T' ('any P' and 'any P') are expected to be equal}} // expected-note@-3 {{arguments to generic parameter 'T' ('any P' and 'any P') are expected to be equal}} func g1(x: G) -> G> { return x // expected-error {{cannot convert return expression of type 'G' to return type 'G>'}} } func g2(x: G>) -> G { return x // expected-error {{cannot convert return expression of type 'G>' to return type 'G'}} } func g3(x: G>) -> G> { return x // expected-error {{cannot convert return expression of type 'G>' to return type 'G>'}} } func h1(x: (any P)?) -> (any P)? { return x // expected-error {{cannot convert return expression of type '(any P)?' to return type '(any P)?'}} // expected-note@-1 {{arguments to generic parameter 'Wrapped' ('any P' and 'any P') are expected to be equal}} } func h2(x: (any P)?) -> (any P)? { return x // okay } func h3(x: (any P)?) -> (any P)? { return x // expected-error {{cannot convert return expression of type '(any P)?' to return type '(any P)?'}} } func generic1(x: any P) -> T { return x.f() }