Skip to content

Commit fdcf53c

Browse files
committed
Tests: Test conformance checker with witnesses in unavailable extensions.
A protocol conformance witness must be as available as its requirement. In Swift 6.1 and earlier, the conformance checker failed to note that witnesses in unavailable extensions are unavailable. That bug was fixed by a previous change, but there was no test case covering it so the difference in behavior was not acknowledged. Related to rdar://143466010.
1 parent 95dca81 commit fdcf53c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/decl/protocol/req/unavailable.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Bar : NonObjCProto { // expected-error {{type 'Bar' does not conform to pr
2626

2727
// Complain about unavailable witnesses (error in Swift 4, warning in Swift 3)
2828
protocol P {
29-
func foo(bar: Foo) // expected-note 2 {{requirement 'foo(bar:)' declared here}}
29+
func foo(bar: Foo) // expected-note 3 {{requirement 'foo(bar:)' declared here}}
3030
}
3131

3232
struct ConformsToP : P { // expected-error{{type 'ConformsToP' does not conform to protocol 'P'}}
@@ -64,6 +64,14 @@ extension ConformsToP5: P {
6464
func foo(bar: Foo) { }
6565
}
6666

67+
struct ConformsToP6: P {} // expected-error{{type 'ConformsToP6' does not conform to protocol 'P'}}
68+
// expected-error@-1 {{unavailable instance method 'foo(bar:)' was used to satisfy a requirement of protocol 'P'}}
69+
70+
@available(*, unavailable)
71+
extension ConformsToP6 {
72+
func foo(bar: Foo) { } // expected-note {{'foo(bar:)' declared here}}
73+
}
74+
6775
@available(*, unavailable)
6876
enum UnavailableEnum {
6977
struct ConformsToP6: P {

0 commit comments

Comments
 (0)