@@ -824,13 +824,13 @@ func test_keypath_with_method_refs() {
824
824
static func bar( ) -> Int { return 0 }
825
825
}
826
826
827
- let _: KeyPath < S , Int > = \. foo // expected-error {{key path cannot refer to instance method 'foo()'}}
827
+ let _: KeyPath < S , Int > = \. foo
828
828
// expected-error@-1 {{cannot assign value of type 'KeyPath<S, () -> Int>' to type 'KeyPath<S, Int>'}}
829
829
// 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 '}}
831
831
// expected-error@-1 {{cannot assign value of type 'KeyPath<S, () -> Int>' to type 'KeyPath<S, Int>'}}
832
832
// 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
834
834
835
835
struct A {
836
836
func foo( ) -> B { return B ( ) }
@@ -841,10 +841,10 @@ func test_keypath_with_method_refs() {
841
841
var bar : Int = 42
842
842
}
843
843
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 }}
848
848
}
849
849
850
850
// https://github.com/apple/swift/issues/54961
@@ -856,7 +856,7 @@ protocol Zonk {
856
856
typealias Blatz = ( gloop: String , zoop: Zonk ? )
857
857
858
858
func 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)
860
860
}
861
861
862
862
// https://github.com/apple/swift/issues/52867
@@ -1091,8 +1091,8 @@ func testSyntaxErrors() {
1091
1091
1092
1092
// https://github.com/apple/swift/issues/56996
1093
1093
func 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' }}
1096
1096
_ = \Int // expected-error {{key path must have at least one component}}
1097
1097
_ = \Int ? // expected-error {{key path must have at least one component}}
1098
1098
_ = \Int . // expected-error {{invalid component of Swift key path}}
0 commit comments