Skip to content

Commit 0a29962

Browse files
committed
Added: Test cases for the platform deprecation, unavailable and platform unavailable PrintAsObjC
1 parent b3a0a5e commit 0a29962

File tree

2 files changed

+344
-67
lines changed

2 files changed

+344
-67
lines changed

test/PrintAsObjC/availability-real-sdk.swift

Lines changed: 121 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,42 @@
88

99

1010
// CHECK-LABEL: @interface NSArray<ObjectType> (SWIFT_EXTENSION(main))
11-
// CHECK-NEXT: - (id _Nonnull)methodDeprecatedInFavorOfReverseObjectEnumerator SWIFT_WARN_UNUSED_RESULT
11+
// CHECK-NEXT: - (id _Nonnull)deprecatedMethodInFavorOfReverseObjectEnumerator SWIFT_WARN_UNUSED_RESULT
1212
// CHECK-SAME: SWIFT_DEPRECATED_MSG("This method is deprecated in favor to the old reverseObjectEnumerator method", "reverseObjectEnumerator");
13-
// CHECK-NEXT: - (NSArray * _Nonnull)methodDeprecatedInFavorOfAddingObjectWithObject:(id _Nonnull)object SWIFT_WARN_UNUSED_RESULT
13+
// CHECK-NEXT: - (id _Nonnull)deprecatedMethodOnMacOSInFavorOfReverseObjectEnumerator SWIFT_WARN_UNUSED_RESULT
14+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedMethodOnMacOSInFavorOfReverseObjectEnumerator' has been renamed to 'reverseObjectEnumerator': This method is deprecated in favor to the old reverseObjectEnumerator method");
15+
// CHECK-NEXT: - (id _Nonnull)unavailableMethodInFavorOfReverseObjectEnumerator SWIFT_WARN_UNUSED_RESULT
16+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInFavorOfReverseObjectEnumerator' has been renamed to 'reverseObjectEnumerator': This method is unavailable in favor to the old reverseObjectEnumerator method");
17+
// CHECK-NEXT: - (id _Nonnull)unavailableMethodOnMacOSInFavorOfReverseObjectEnumerator SWIFT_WARN_UNUSED_RESULT
18+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableMethodOnMacOSInFavorOfReverseObjectEnumerator' has been renamed to 'reverseObjectEnumerator': This method is unavailable in favor to the old reverseObjectEnumerator method");
19+
// CHECK-NEXT: - (NSArray * _Nonnull)deprecatedMethodInFavorOfAddingObjectWithObject:(id _Nonnull)object SWIFT_WARN_UNUSED_RESULT
1420
// CHECK-SAME: SWIFT_DEPRECATED_MSG("This method is deprecated in favor to the old adding method", "arrayByAddingObject:");
15-
21+
// CHECK-NEXT: - (NSArray * _Nonnull)deprecatedMethodOnMacOSInFavorOfAddingObjectWithObject:(id _Nonnull)object SWIFT_WARN_UNUSED_RESULT
22+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedMethodOnMacOSInFavorOfAddingObject' has been renamed to 'arrayByAddingObject:': This method is deprecated in favor to the old adding method");
23+
// CHECK-NEXT: - (NSArray * _Nonnull)unavailableMethodInFavorOfAddingObjectWithObject:(id _Nonnull)object SWIFT_WARN_UNUSED_RESULT
24+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInFavorOfAddingObject' has been renamed to 'arrayByAddingObject:': This method is unavailable in favor to the old adding method");
25+
// CHECK-NEXT: - (NSArray * _Nonnull)unavailableMethodOnMacOSInFavorOfAddingObjectWithObject:(id _Nonnull)object SWIFT_WARN_UNUSED_RESULT
26+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableMethodOnMacOSInFavorOfAddingObject' has been renamed to 'arrayByAddingObject:': This method is unavailable in favor to the old adding method");
1627
// CHECK-NEXT: @end
1728

1829
// CHECK-LABEL: @interface SubClassOfSet : NSSet
19-
// CHECK-NEXT: - (id _Nonnull)methodDeprecatedInFavorOfAnyObject SWIFT_WARN_UNUSED_RESULT
30+
// CHECK-NEXT: - (id _Nonnull)deprecatedMethodInFavorOfAnyObject SWIFT_WARN_UNUSED_RESULT
2031
// CHECK-SAME: SWIFT_DEPRECATED_MSG("This method is deprecated in favor to the old anyObject method", "anyObject");
32+
// CHECK-NEXT: - (id _Nonnull)deprecatedMethodOnMacOSInFavorOfAnyObject SWIFT_WARN_UNUSED_RESULT
33+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedMethodOnMacOSInFavorOfAnyObject' has been renamed to 'anyObject': This method is deprecated in favor to the old anyObject method");
34+
// CHECK-NEXT: - (id _Nonnull)unavailableMethodInFavorOfAnyObject SWIFT_WARN_UNUSED_RESULT
35+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailableMethodInFavorOfAnyObject' has been renamed to 'anyObject': This method is unavailable in favor to the old anyObject method");
36+
// CHECK-NEXT: - (id _Nonnull)unavailableMethodOnMacOSInFavorOfAnyObject SWIFT_WARN_UNUSED_RESULT
37+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableMethodOnMacOSInFavorOfAnyObject' has been renamed to 'anyObject': This method is unavailable in favor to the old anyObject method");
2138
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger deprecatedPropertyInFavorOfCount
2239
// CHECK-SAME: SWIFT_DEPRECATED_MSG("This property is deprecated in favor to the old count property", "count");
40+
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger deprecatedOnMacOSPropertyInFavorOfCount
41+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'deprecatedOnMacOSPropertyInFavorOfCount' has been renamed to 'count': This property is deprecated in favor to the old count property");
42+
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger unavailablePropertyInFavorOfCount
43+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'unavailablePropertyInFavorOfCount' has been renamed to 'count': This property is unavailable in favor to the old count property");
44+
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger unavailableOnMacOSPropertyInFavorOfCount
45+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'unavailableOnMacOSPropertyInFavorOfCount' has been renamed to 'count': This property is unavailable in favor to the old count property");
46+
2347
// CHECK-NEXT: - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
2448
// CHECK-NEXT: - (nonnull instancetype)initWithObjects:(id _Nonnull const * _Nullable)objects count:(NSUInteger)cnt OBJC_DESIGNATED_INITIALIZER;
2549
// CHECK-NEXT: - (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)aDecoder OBJC_DESIGNATED_INITIALIZER;
@@ -30,33 +54,102 @@ import Foundation
3054

3155

3256
public class SubClassOfSet: NSSet {
33-
@available(*, deprecated,
34-
message: "This method is deprecated in favor to the old anyObject method",
35-
renamed: "anyObject()")
36-
@objc func methodDeprecatedInFavorOfAnyObject() -> Any { return 0 }
37-
38-
@available(*, deprecated,
39-
message: "This property is deprecated in favor to the old count property",
40-
renamed: "count")
41-
@objc var deprecatedPropertyInFavorOfCount: Int {
42-
get {
43-
return 0
44-
}
45-
}
57+
@available(*, deprecated,
58+
message: "This method is deprecated in favor to the old anyObject method",
59+
renamed: "anyObject()")
60+
@objc func deprecatedMethodInFavorOfAnyObject() -> Any { return 0 }
61+
@available(macOS, deprecated,
62+
message: "This method is deprecated in favor to the old anyObject method",
63+
renamed: "anyObject()")
64+
@objc func deprecatedMethodOnMacOSInFavorOfAnyObject() -> Any { return 0 }
65+
66+
@available(*, unavailable,
67+
message: "This method is unavailable in favor to the old anyObject method",
68+
renamed: "anyObject()")
69+
@objc func unavailableMethodInFavorOfAnyObject() -> Any { return 0 }
70+
@available(macOS, unavailable,
71+
message: "This method is unavailable in favor to the old anyObject method",
72+
renamed: "anyObject()")
73+
@objc func unavailableMethodOnMacOSInFavorOfAnyObject() -> Any { return 0 }
74+
75+
@available(*, deprecated,
76+
message: "This property is deprecated in favor to the old count property",
77+
renamed: "count")
78+
@objc var deprecatedPropertyInFavorOfCount: Int {
79+
get {
80+
return 0
81+
}
82+
}
83+
@available(macOS, deprecated,
84+
message: "This property is deprecated in favor to the old count property",
85+
renamed: "count")
86+
@objc var deprecatedOnMacOSPropertyInFavorOfCount: Int {
87+
get {
88+
return 0
89+
}
90+
}
91+
@available(*, unavailable,
92+
message: "This property is unavailable in favor to the old count property",
93+
renamed: "count")
94+
@objc var unavailablePropertyInFavorOfCount: Int {
95+
get {
96+
return 0
97+
}
98+
}
99+
@available(macOS, unavailable,
100+
message: "This property is unavailable in favor to the old count property",
101+
renamed: "count")
102+
@objc var unavailableOnMacOSPropertyInFavorOfCount: Int {
103+
get {
104+
return 0
105+
}
106+
}
46107
}
47108

48109

49110
extension NSArray {
50-
@available(*, deprecated,
51-
message: "This method is deprecated in favor to the old reverseObjectEnumerator method",
52-
renamed: "reverseObjectEnumerator()")
53-
@objc func methodDeprecatedInFavorOfReverseObjectEnumerator() -> Any { return 0 }
54-
55-
@available(*, deprecated,
56-
message: "This method is deprecated in favor to the old adding method",
57-
renamed: "adding(_:)")
58-
@objc func methodDeprecatedInFavorOfAddingObject(object: Any) -> NSArray {
59-
return self.adding(object) as NSArray
60-
}
111+
@available(*, deprecated,
112+
message: "This method is deprecated in favor to the old reverseObjectEnumerator method",
113+
renamed: "reverseObjectEnumerator()")
114+
@objc func deprecatedMethodInFavorOfReverseObjectEnumerator() -> Any { return 0 }
115+
@available(macOS, deprecated,
116+
message: "This method is deprecated in favor to the old reverseObjectEnumerator method",
117+
renamed: "reverseObjectEnumerator()")
118+
@objc func deprecatedMethodOnMacOSInFavorOfReverseObjectEnumerator() -> Any { return 0 }
119+
120+
@available(*, unavailable,
121+
message: "This method is unavailable in favor to the old reverseObjectEnumerator method",
122+
renamed: "reverseObjectEnumerator()")
123+
@objc func unavailableMethodInFavorOfReverseObjectEnumerator() -> Any { return 0 }
124+
@available(macOS, unavailable,
125+
message: "This method is unavailable in favor to the old reverseObjectEnumerator method",
126+
renamed: "reverseObjectEnumerator()")
127+
@objc func unavailableMethodOnMacOSInFavorOfReverseObjectEnumerator() -> Any { return 0 }
128+
129+
130+
@available(*, deprecated,
131+
message: "This method is deprecated in favor to the old adding method",
132+
renamed: "adding(_:)")
133+
@objc func deprecatedMethodInFavorOfAddingObject(object: Any) -> NSArray {
134+
return self.adding(object) as NSArray
135+
}
136+
@available(macOS, deprecated,
137+
message: "This method is deprecated in favor to the old adding method",
138+
renamed: "adding(_:)")
139+
@objc func deprecatedMethodOnMacOSInFavorOfAddingObject(object: Any) -> NSArray {
140+
return self.adding(object) as NSArray
141+
}
142+
@available(*, unavailable,
143+
message: "This method is unavailable in favor to the old adding method",
144+
renamed: "adding(_:)")
145+
@objc func unavailableMethodInFavorOfAddingObject(object: Any) -> NSArray {
146+
return self.adding(object) as NSArray
147+
}
148+
@available(macOS, unavailable,
149+
message: "This method is unavailable in favor to the old adding method",
150+
renamed: "adding(_:)")
151+
@objc func unavailableMethodOnMacOSInFavorOfAddingObject(object: Any) -> NSArray {
152+
return self.adding(object) as NSArray
153+
}
61154
}
62155

0 commit comments

Comments
 (0)