Repository: apple/swift
File: test/Constraints/static_members_on_protocol_in_generic_context.swift (Swift)

Code before:
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test(.generic(42).other)
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
test(.generic(S())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test(.generic(G<Int>())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test(.genericWithReqs([S()])) // expected-error {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-1 {{static method 'genericWithReqs' requires that '[any Q]' conform to 'Q'}}
test(.genericWithReqs([S()]).doesntExist) // expected-error {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-1 {{value of type 'any Q' has no member 'doesntExist'}}
// expected-error@-2 {{static method 'genericWithReqs' requires that '[any Q]' conform to 'Q'}}
test(.genericWithReqs([42]))
// expected-error@-1 {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{static method 'genericWithReqs' requires that '[any Q]' conform to 'Q'}}
// expected-error@-3 {{cannot convert value of type 'Int' to expected element type 'any Q'}}
test(.genericWithReqs(()))
// expected-error@-1 {{type '()' cannot conform to 'Collection'}}
// expected-error@-2 {{type '()' cannot conform to 'Q'}}
// expected-error@-3 {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-note@-4 2 {{only concrete types such as structs, enums and classes can conform to protocols}}

test_combo(.doesntExist) // expected-error {{reference to member 'doesntExist' cannot be resolved without a contextual type}}
test_combo(.doesnt.exist()) // expected-error {{reference to member 'doesnt' cannot be resolved without a contextual type}}
test_combo(.invalidProp)
// expected-error@-1 {{contextual member reference to static property 'invalidProp' requires 'Self' constraint in the protocol extension}}
test_combo(.invalidProp.doesntExist) //FIXME Should be reporting that Int has no doesntExist if P&Q lookup fixed
// expected-error@-1{{type 'Q' has no member 'invalidProp'}}
test_combo(.invalidMethod())
// expected-error@-1 {{failed to produce diagnostic for expression}}
// {{contextual member reference to static method 'invalidMethod()' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(42))
// expected-error@-1 {{failed to produce diagnostic for expression}}
// {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(S())) // expected-error {{failed to produce diagnostic for expression}}
// {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(G<Int>())) // expected-error {{failed to produce diagnostic for expression}}
// {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.genericWithReqs([S()])) //FIXME error on Q membership an error on P&Q lookup, contextual error should occur
// {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{type 'Q' has no member 'genericWithReqs'}}
test_combo(.genericWithReqs([42])) //FIXME error on Q membership an error on P&Q lookup, contextual error should occur
// {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{type 'Q' has no member 'genericWithReqs'}}
test_combo(.genericWithReqs(())) //FIXME error on Q membership an error on P&Q lookup, other errors should occur
// expected-error@-1{{type 'Q' has no member 'genericWithReqs'}}
// {{type '()' cannot conform to 'Collection'}}
// {{only concrete types such as structs, enums and classes can conform to protocols}}
// {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}

protocol TestWithAssoc {
  associatedtype U

Review comment (suggestion):
Minor nit, this allows it to be highlighted in Xcode:

```suggestion
test_combo(.invalidProp.doesntExist) // FIXME: Should be reporting that Int has no doesntExist if P&Q lookup fixed
```

Same goes for the others below

Code after:
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
test(.generic(S())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test(.generic(G<Int>())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test(.genericWithReqs([S()])) // expected-error {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
test(.genericWithReqs([S()]).doesntExist) // expected-error {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-1 {{value of type 'any Q' has no member 'doesntExist'}}
test(.genericWithReqs([42]))
// expected-error@-1 {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// expected-error@-2 {{cannot convert value of type 'Int' to expected element type 'any Q'}}
test(.genericWithReqs(()))
// expected-error@-1 {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}

test_combo(.doesntExist) // expected-error {{reference to member 'doesntExist' cannot be resolved without a contextual type}}
test_combo(.doesnt.exist()) // expected-error {{reference to member 'doesnt' cannot be resolved without a contextual type}}
test_combo(.invalidProp)
// expected-error@-1 {{contextual member reference to static property 'invalidProp' requires 'Self' constraint in the protocol extension}}
test_combo(.invalidProp.doesntExist) //FIXME: Requires protocol conformance fix for expected two messages below
// expected-error@-1{{type 'Q' has no member 'invalidProp'}}
// {{contextual member reference to static property 'invalidProp' requires 'Self' constraint in the protocol extension}}
// {{value of type 'Int' has no member 'doesntExist'}}
test_combo(.invalidMethod())
// expected-error@-1{{contextual member reference to static method 'invalidMethod()' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(42))
// expected-error@-1{{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(S()))
// expected-error@-1{{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.generic(G<Int>()))
//expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
test_combo(.genericWithReqs([S()]))
// expected-error@-1{{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
test_combo(.genericWithReqs([42])) //FIXME: Requires protocol conformance fix for expected two messages below
// expected-error@-1{{failed to produce diagnostic for expression}}
// {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}
// {{cannot convert value of type 'Int' to expected element type 'any Q'}}
test_combo(.genericWithReqs(()))
// expected-error@-1{{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}

protocol TestWithAssoc {
  associatedtype U
}

struct S_With_U : P {
  typealias U = Int
}

extension TestWithAssoc where U == Int { // expected-note {{missing same-type requirement on 'Self'}} {{39-39=, Self == <#Type#> }}
  static var intVar: Int { 42 }
}

func test_fixit_with_where_clause() {