Skip to content

Commit 585350d

Browse files
Add example code as test
1 parent d218e7e commit 585350d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/decl/protocol/req/unavailable.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,24 @@ struct ConformsToP2 {
4040
}
4141
extension ConformsToP2: P {} // expected-error{{type 'ConformsToP2' does not conform to protocol 'P'}}
4242
// expected-error@-1 {{unavailable instance method 'foo(bar:)' was used to satisfy a requirement of protocol 'P'}}
43+
44+
45+
// Include message string from @available attribute if provided
46+
protocol Unavail {
47+
associatedtype T
48+
func req() // expected-note {{requirement 'req()' declared here}}
49+
}
50+
extension Unavail {
51+
func req() {}
52+
}
53+
extension Unavail where T == Self {
54+
@available(*, unavailable, message: "write it yourself") func req() {} // expected-note {{'req()' declared here}}
55+
}
56+
57+
struct NonSelfT: Unavail {
58+
typealias T = Int
59+
}
60+
struct SelfT: Unavail { // expected-error {{type 'SelfT' does not conform to protocol 'Unavail'}}
61+
// expected-error@-1 {{unavailable instance method 'req()' was used to satisfy a requirement of protocol 'Unavail': write it yourself}}
62+
typealias T = SelfT
63+
}

0 commit comments

Comments
 (0)