-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathdeprecated.swift
60 lines (45 loc) · 1.68 KB
/
deprecated.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// RUN: %target-typecheck-verify-swift
protocol DeprecatedRequirement {
@available(*, deprecated)
func f()
}
extension DeprecatedRequirement {
@available(*, deprecated)
func f() {}
}
// No warning if both the requirement and the default implementation are deprecated
struct S1: DeprecatedRequirement {}
protocol DeprecatedDefault {
func f() // expected-note {{requirement 'f()' declared here}}
}
extension DeprecatedDefault {
@available(*, deprecated)
func f() {} // expected-note {{'f()' declared here}}
}
// expected-warning@+1 {{deprecated default implementation is used to satisfy instance method 'f()' required by protocol 'DeprecatedDefault'}}{{documentation-file=deprecated-declaration}}
struct S2: DeprecatedDefault {}
// No warning if the conformance itself is deprecated
@available(*, deprecated)
struct S3: DeprecatedDefault {
}
struct S4: DeprecatedDefault {
func f() {}
}
struct S5 {}
// No warning if the conformance itself is deprecated
@available(*, deprecated)
extension S5: DeprecatedDefault {}
@available(*, deprecated)
enum UnavailableEnum {
struct Nested: DeprecatedDefault {}
}
// Include message string from @available attribute if provided
protocol DeprecatedDefaultWithMessage {
func f() // expected-note {{requirement 'f()' declared here}}
}
extension DeprecatedDefaultWithMessage {
@available(*, deprecated, message: "write it yourself")
func f() {} // expected-note {{'f()' declared here}}
}
// expected-warning@+1 {{deprecated default implementation is used to satisfy instance method 'f()' required by protocol 'DeprecatedDefaultWithMessage': write it yourself}}{{documentation-file=deprecated-declaration}}
struct S6: DeprecatedDefaultWithMessage {}