Skip to content

Commit 7a9bca9

Browse files
committed
Added: Overloaded initializer test cases
1 parent c52b9f9 commit 7a9bca9

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

test/PrintAsObjC/availability.swift

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,17 @@
124124
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'__makeUnavailableOnMacOSAvailability' has been renamed to 'unavailableAvailabilityWithValue:': use something else");
125125

126126
// CHECK-NEXT: - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
127-
// CHECK-NEXT: - (nonnull instancetype)initWithX:(NSInteger)_ OBJC_DESIGNATED_INITIALIZER SWIFT_AVAILABILITY(macos,introduced=10.10);
127+
// CHECK-NEXT: - (nonnull instancetype)initWithX:(NSInteger)x OBJC_DESIGNATED_INITIALIZER SWIFT_AVAILABILITY(macos,introduced=10.10);
128+
// CHECK-NEXT: - (nonnull instancetype)initWithFirst:(NSInteger)first second:(NSInteger)second OBJC_DESIGNATED_INITIALIZER;
129+
// CHECK-NEXT: - (nonnull instancetype)initWithDeprecatedFirst:(NSInteger)first second:(NSInteger)second OBJC_DESIGNATED_INITIALIZER
130+
// CHECK-SAME: SWIFT_DEPRECATED_MSG("", "initWithFirst:second:");
131+
// CHECK-NEXT: - (nonnull instancetype)initWithDeprecatedOnMacOSFirst:(NSInteger)first second:(NSInteger)second OBJC_DESIGNATED_INITIALIZER
132+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'init' has been renamed to 'initWithFirst:second:'");
133+
// CHECK-NEXT: - (nonnull instancetype)initWithUnavailableFirst:(NSInteger)first second:(NSInteger)second OBJC_DESIGNATED_INITIALIZER
134+
// CHECK-SAME: SWIFT_UNAVAILABLE_MSG("'init' has been renamed to 'initWithFirst:second:'");
135+
// CHECK-NEXT: - (nonnull instancetype)initWithUnavailableOnMacOSFirst:(NSInteger)first second:(NSInteger)second OBJC_DESIGNATED_INITIALIZER
136+
// CHECK-SAME: SWIFT_AVAILABILITY(macos,unavailable,message="'init' has been renamed to 'initWithFirst:second:'");
137+
128138
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger simpleProperty;
129139
// CHECK-NEXT: @property (nonatomic) NSInteger alwaysUnavailableProperty SWIFT_UNAVAILABLE_MSG("'alwaysUnavailableProperty' has been renamed to 'baz': whatever");
130140
// CHECK-NEXT: @property (nonatomic, readonly) NSInteger alwaysDeprecatedProperty SWIFT_DEPRECATED_MSG("use something else", "quux");
@@ -163,9 +173,12 @@
163173
// CHECK-LABEL: @interface AvailabilitySub
164174
// CHECK-NEXT: - (nonnull instancetype)init SWIFT_UNAVAILABLE;
165175
// CHECK-NEXT: + (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
166-
// CHECK-NEXT: - (nonnull instancetype)initWithX:(NSInteger)_ SWIFT_UNAVAILABLE;
176+
// CHECK-NEXT: - (nonnull instancetype)initWithX:(NSInteger)x SWIFT_UNAVAILABLE;
167177
// CHECK-NEXT: - (nonnull instancetype)initWithDeprecatedZ:(NSInteger)deprecatedZ OBJC_DESIGNATED_INITIALIZER SWIFT_DEPRECATED_MSG("init(deprecatedZ:) was deprecated. Use the new one instead", "initWithNewZ:")
168178
// CHECK-NEXT: - (nonnull instancetype)initWithNewZ:(NSInteger)z OBJC_DESIGNATED_INITIALIZER;
179+
// CHECK-NEXT: - (nonnull instancetype)initWithFirst:(NSInteger)first second:(NSInteger)second SWIFT_UNAVAILABLE;
180+
// CHECK-NEXT: - (nonnull instancetype)initWithDeprecatedFirst:(NSInteger)first second:(NSInteger)second SWIFT_UNAVAILABLE;
181+
// CHECK-NEXT: - (nonnull instancetype)initWithDeprecatedOnMacOSFirst:(NSInteger)first second:(NSInteger)second SWIFT_UNAVAILABLE;
169182
// CHECK-NEXT: @end
170183

171184
// CHECK-LABEL: SWIFT_AVAILABILITY(macos,deprecated=0.0.1,message="'DeprecatedAvailability' has been renamed to 'SWTReplacementAvailable'")
@@ -431,8 +444,23 @@
431444

432445
@objc init() {}
433446
@available(macOS 10.10, *)
434-
@objc init(x _: Int) {}
435-
447+
@objc init(x: Int) {}
448+
449+
@objc init(first: Int, second: Int) {}
450+
init(first: Double, second: Double) {}
451+
452+
@available(*, deprecated, renamed: "init(first:second:)")
453+
@objc init(deprecatedFirst first: Int, second: Int) {}
454+
455+
@available(macOS, deprecated, renamed: "init(first:second:)")
456+
@objc init(deprecatedOnMacOSFirst first: Int, second: Int) {}
457+
458+
@available(*, unavailable, renamed: "init(first:second:)")
459+
@objc init(unavailableFirst first: Int, second: Int) {}
460+
461+
@available(macOS, unavailable, renamed: "init(first:second:)")
462+
@objc init(unavailableOnMacOSFirst first: Int, second: Int) {}
463+
436464
@objc var simpleProperty: Int {
437465
get {
438466
return 100
@@ -536,7 +564,6 @@
536564
extension Availability {
537565
@objc func extensionAvailability(_: WholeClassAvailability) {}
538566

539-
540567
@available(macOS, deprecated: 10.10)
541568
@objc var propertyDeprecatedInsideExtension: Int {
542569
get {
@@ -548,7 +575,7 @@ extension Availability {
548575
@objc class AvailabilitySub: Availability {
549576
private override init() { super.init() }
550577
@available(macOS 10.10, *)
551-
private override init(x _: Int) { super.init() }
578+
private override init(x: Int) { super.init() }
552579
@available(*, deprecated, message: "init(deprecatedZ:) was deprecated. Use the new one instead", renamed: "init(z:)")
553580
@objc init(deprecatedZ: Int) { super.init() }
554581
@objc(initWithNewZ:) init(z: Int) { super.init() }

0 commit comments

Comments
 (0)