From bcc49cf708033ba3701a267c919f2d20affba2bf Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Tue, 12 Aug 2025 20:05:04 -0700 Subject: [PATCH] Tests: Add a test for rdar://158172056. The bug tracked by rdar://158172056 was already fixed by https://github.com/swiftlang/swift/pull/83607 but this additional test case is needed to ensure that conformances to Obj-C protocols with obsolete requirements imported under legacy spellings not regress again. --- .../clang-importer-sdk/usr/include/Foundation.h | 8 ++++++++ test/decl/protocol/conforms/objc_renamed.swift | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/decl/protocol/conforms/objc_renamed.swift diff --git a/test/Inputs/clang-importer-sdk/usr/include/Foundation.h b/test/Inputs/clang-importer-sdk/usr/include/Foundation.h index 60998cffdaaa5..03e3240480fb3 100644 --- a/test/Inputs/clang-importer-sdk/usr/include/Foundation.h +++ b/test/Inputs/clang-importer-sdk/usr/include/Foundation.h @@ -1243,3 +1243,11 @@ void takeNullableId(_Nullable id); @interface PaletteDescriptor : NSObject @property (readonly, nonnull) ColorArray *colors; @end + +@protocol NSIndexable +- (id)objectAtIndex:(NSInteger)index; +@end + +@interface NSCouldConformToIndexable : NSObject +- (id)objectAtIndex:(NSInteger)index; +@end diff --git a/test/decl/protocol/conforms/objc_renamed.swift b/test/decl/protocol/conforms/objc_renamed.swift new file mode 100644 index 0000000000000..da76d82b5a324 --- /dev/null +++ b/test/decl/protocol/conforms/objc_renamed.swift @@ -0,0 +1,15 @@ +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s + +// REQUIRES: objc_interop + +import Foundation + +extension NSCouldConformToIndexable: @retroactive NSIndexable { +} + +extension NSCouldConformToIndexable { + func testIndex(_ i: Int) { + _ = objectAtIndex(i) // expected-error {{'objectAtIndex' has been renamed to 'object(at:)'}} + _ = object(at: i) + } +}