Skip to content

Commit f7c198c

Browse files
committed
[Tests] Update tests.
1 parent ba40378 commit f7c198c

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

test/Constraints/rdar68155466.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import Foundation
1010
}
1111

1212
// FIXME: the diagnostic below ideally should have been emitted (rdar://106241733)
13-
struct Loop< // note {{required by generic struct 'Loop' where 'ID' = '() -> Int'}}
13+
struct Loop<
14+
// expected-note@-1 {{required by generic struct 'Loop' where 'ID' = '() -> Int'}}
1415
Data : RandomAccessCollection,
1516
ID : Hashable,
1617
Content
@@ -25,6 +26,8 @@ func data() -> [A] {
2526
return []
2627
}
2728

28-
_ = Loop(data(), id: \.uniqueID) { $0 } // expected-error {{key path cannot refer to instance method 'uniqueID()'}}
29-
// FIXME: the diagnostics below ideally should have been emitted (rdar://106241733)
30-
// error@-1 {{type '() -> Int' cannot conform to 'Hashable'}} note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
29+
_ = Loop(data(), id: \.uniqueID) { $0 }
30+
// expected-error@-1 {{type '() -> Int' cannot conform to 'Hashable'}}
31+
// expected-note@-2 {{only concrete types such as structs, enums and classes can conform to protocols}}
32+
33+

test/attr/attr_dynamic_member_lookup.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ func test_chain_of_recursive_lookups(_ lens: Lens<Lens<Lens<Point>>>) {
668668
_ = \Lens<Lens<Point>>.obj.x
669669
}
670670

671-
// KeyPath Dynamic Member Lookup can't refer to methods, mutating setters and static members
672-
// because of the KeyPath limitations
671+
// KeyPath Dynamic Member Lookup can't refer mutating setters because of the
672+
// KeyPath limitations
673673
func invalid_refs_through_dynamic_lookup() {
674674
struct S {
675675
static var foo: Int = 42
@@ -683,9 +683,9 @@ func invalid_refs_through_dynamic_lookup() {
683683

684684
func test(_ lens: A<S>) {
685685
_ = lens.foo // expected-error {{static member 'foo' cannot be used on instance of type 'S'}}
686-
_ = lens.bar() // expected-error {{dynamic key path member lookup cannot refer to instance method 'bar()'}}
687-
_ = lens.bar().faz + 1 // expected-error {{dynamic key path member lookup cannot refer to instance method 'bar()'}}
688-
_ = lens.baz("hello") // expected-error {{dynamic key path member lookup cannot refer to static method 'baz'}}
686+
_ = lens.bar()
687+
_ = lens.bar().faz + 1
688+
_ = lens.baz("hello") // expected-error {{static member 'baz' cannot be used on instance of type 'S'}}
689689
}
690690
}
691691

test/expr/unary/keypath/keypath.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {
856856
typealias Blatz = (gloop: String, zoop: Zonk?)
857857

858858
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)
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
10931093
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'}}
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

Comments
 (0)