@@ -824,13 +824,13 @@ func test_keypath_with_method_refs() {
824824 static func bar( ) -> Int { return 0 }
825825 }
826826
827- let _: KeyPath < S , Int > = \. foo // expected-error {{key path cannot refer to instance method 'foo()'}}
827+ let _: KeyPath < S , Int > = \. foo
828828 // expected-error@-1 {{cannot assign value of type 'KeyPath<S, () -> Int>' to type 'KeyPath<S, Int>'}}
829829 // expected-note@-2 {{arguments to generic parameter 'Value' ('() -> Int' and 'Int') are expected to be equal}}
830- let _: KeyPath < S , Int > = \. bar // expected-error {{key path cannot refer to static method 'bar() '}}
830+ let _: KeyPath < S , Int > = \. bar // expected-error {{static member 'bar()' cannot be used on instance of type 'S '}}
831831 // expected-error@-1 {{cannot assign value of type 'KeyPath<S, () -> Int>' to type 'KeyPath<S, Int>'}}
832832 // expected-note@-2 {{arguments to generic parameter 'Value' ('() -> Int' and 'Int') are expected to be equal}}
833- let _ = \S . Type. bar // expected-error {{key path cannot refer to static method 'bar()'}}
833+ let _ = \S . Type. bar
834834
835835 struct A {
836836 func foo( ) -> B { return B ( ) }
@@ -841,10 +841,10 @@ func test_keypath_with_method_refs() {
841841 var bar : Int = 42
842842 }
843843
844- let _: KeyPath < A , Int > = \. foo. bar // expected-error {{key path cannot refer to instance method 'foo()' }}
845- let _: KeyPath < A , Int > = \. faz. bar // expected-error {{key path cannot refer to static method 'faz() '}}
846- let _ = \A . foo. bar // expected-error {{key path cannot refer to instance method 'foo()' }}
847- let _ = \A . Type. faz. bar // expected-error {{key path cannot refer to static method 'faz()' }}
844+ let _: KeyPath < A , Int > = \. foo. bar // expected-error {{type of expression is ambiguous without a type annotation }}
845+ let _: KeyPath < A , Int > = \. faz. bar // expected-error {{static member 'faz()' cannot be used on instance of type 'A '}}
846+ let _ = \A . foo. bar // expected-error {{type of expression is ambiguous without a type annotation }}
847+ let _ = \A . Type. faz. bar // expected-error {{type of expression is ambiguous without a type annotation }}
848848}
849849
850850// https://github.com/apple/swift/issues/54961
@@ -856,7 +856,7 @@ protocol Zonk {
856856typealias Blatz = ( gloop: String , zoop: Zonk ? )
857857
858858func f_54961( fleep: [ Blatz ] ) {
859- fleep. compactMap ( \. zoop? . wargle) // expected-error {{key path cannot refer to instance method 'wargle()'}}
859+ let _ = fleep. compactMap ( \. zoop? . wargle)
860860}
861861
862862// https://github.com/apple/swift/issues/52867
@@ -1091,8 +1091,8 @@ func testSyntaxErrors() {
10911091
10921092// https://github.com/apple/swift/issues/56996
10931093func f_56996 ( ) {
1094- _ = \Int . byteSwapped. signum ( ) // expected-error {{invalid component of Swift key path}}
1095- _ = \Int . byteSwapped. init ( ) // expected-error {{invalid component of Swift key path }}
1094+ _ = \Int . byteSwapped. signum ( )
1095+ _ = \Int . byteSwapped. init ( ) // expected-error {{static member 'init()' cannot be used on instance of type 'Int' }}
10961096 _ = \Int // expected-error {{key path must have at least one component}}
10971097 _ = \Int ? // expected-error {{key path must have at least one component}}
10981098 _ = \Int . // expected-error {{invalid component of Swift key path}}
0 commit comments