From 57b2c809b25afe95a6a6f9c3977fce262a4ee958 Mon Sep 17 00:00:00 2001 From: Peter Rong Date: Wed, 4 Jun 2025 09:47:17 -0700 Subject: [PATCH 1/2] [ClangImporter] Add a repro Signed-off-by: Peter Rong --- .../objc_method_with_NSString_clousure.swift | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/ClangImporter/objc_method_with_NSString_clousure.swift diff --git a/test/ClangImporter/objc_method_with_NSString_clousure.swift b/test/ClangImporter/objc_method_with_NSString_clousure.swift new file mode 100644 index 0000000000000..f1ef656260dc5 --- /dev/null +++ b/test/ClangImporter/objc_method_with_NSString_clousure.swift @@ -0,0 +1,20 @@ +// RUN: %empty-directory(%t) +// RUN: split-file %s %t + +// RUN: %target-swift-frontend -emit-silgen %t/Theme.swift -import-objc-header %t/Theme.h | %FileCheck %t/Theme.swift + +// REQUIRES: objc_interop + +//--- Theme.h +#import + +typedef struct ThemeFuncTable { + NSString *_Nonnull (*_Nonnull keyGetter)(); +} ThemeFuncTable; + +//--- Theme.swift +import Theme + +let _ = ThemeFuncTable( + keyGetter: { "SomeTheme" } +) From ce5c9af24a1b9a5c54a7fa051260e104bd781275 Mon Sep 17 00:00:00 2001 From: Peter Rong Date: Fri, 6 Jun 2025 10:32:50 -0700 Subject: [PATCH 2/2] Remove objc_interop Signed-off-by: Peter Rong --- ...ousure.swift => objc_method_with_NSString_closure.swift} | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename test/ClangImporter/{objc_method_with_NSString_clousure.swift => objc_method_with_NSString_closure.swift} (58%) diff --git a/test/ClangImporter/objc_method_with_NSString_clousure.swift b/test/ClangImporter/objc_method_with_NSString_closure.swift similarity index 58% rename from test/ClangImporter/objc_method_with_NSString_clousure.swift rename to test/ClangImporter/objc_method_with_NSString_closure.swift index f1ef656260dc5..21f5fb775a847 100644 --- a/test/ClangImporter/objc_method_with_NSString_clousure.swift +++ b/test/ClangImporter/objc_method_with_NSString_closure.swift @@ -1,12 +1,10 @@ // RUN: %empty-directory(%t) // RUN: split-file %s %t -// RUN: %target-swift-frontend -emit-silgen %t/Theme.swift -import-objc-header %t/Theme.h | %FileCheck %t/Theme.swift - -// REQUIRES: objc_interop +// RUN: not --crash %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enable-objc-interop -emit-silgen %t/Theme.swift -import-objc-header %t/Theme.h //--- Theme.h -#import +#import typedef struct ThemeFuncTable { NSString *_Nonnull (*_Nonnull keyGetter)();