diff --git a/lib/ClangImporter/CFTypeInfo.cpp b/lib/ClangImporter/CFTypeInfo.cpp index dd9128f676b97..cf31fa220e007 100644 --- a/lib/ClangImporter/CFTypeInfo.cpp +++ b/lib/ClangImporter/CFTypeInfo.cpp @@ -53,6 +53,9 @@ CFPointeeInfo CFPointeeInfo::classifyTypedef(const clang::TypedefNameDecl *typedefDecl) { clang::QualType type = typedefDecl->getUnderlyingType(); + if (auto elaborated = type->getAs()) + type = elaborated->desugar(); + if (auto subTypedef = type->getAs()) { if (classifyTypedef(subTypedef->getDecl())) return forTypedef(subTypedef->getDecl()); diff --git a/test/Interop/Cxx/objc-correctness/Inputs/NSTextCheckingResult.h b/test/Interop/Cxx/objc-correctness/Inputs/NSTextCheckingResult.h new file mode 100644 index 0000000000000..4cc986d089920 --- /dev/null +++ b/test/Interop/Cxx/objc-correctness/Inputs/NSTextCheckingResult.h @@ -0,0 +1,12 @@ +#define __CF_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open))) +#if (__cplusplus) +#define CF_OPTIONS(_type, _name) __attribute__((availability(swift,unavailable))) _type _name; enum __CF_OPTIONS_ATTRIBUTES : _name +#else +#define CF_OPTIONS(_type, _name) enum __CF_OPTIONS_ATTRIBUTES _name : _type _name; enum _name : _type +#endif + +typedef CF_OPTIONS(unsigned int, NSTextCheckingType) { + NSTextCheckingTypeOrthography = 1ULL << 0, + NSTextCheckingTypeSpelling = 1ULL << 1, + // ... +}; diff --git a/test/Interop/Cxx/objc-correctness/Inputs/SwiftTextCheckingResult.swift b/test/Interop/Cxx/objc-correctness/Inputs/SwiftTextCheckingResult.swift new file mode 100644 index 0000000000000..851c02ebc6fe7 --- /dev/null +++ b/test/Interop/Cxx/objc-correctness/Inputs/SwiftTextCheckingResult.swift @@ -0,0 +1,5 @@ +import NSTextCheckingResult + +public func foo() -> NSTextCheckingType { + return .orthography +} diff --git a/test/Interop/Cxx/objc-correctness/Inputs/module.modulemap b/test/Interop/Cxx/objc-correctness/Inputs/module.modulemap index 47908d93fed08..2189df2a3f8fd 100644 --- a/test/Interop/Cxx/objc-correctness/Inputs/module.modulemap +++ b/test/Interop/Cxx/objc-correctness/Inputs/module.modulemap @@ -24,3 +24,8 @@ module OSObject { requires objc requires cplusplus } + +module NSTextCheckingResult { + header "NSTextCheckingResult.h" + requires objc +} diff --git a/test/Interop/Cxx/objc-correctness/foundation-string-extensions.swift b/test/Interop/Cxx/objc-correctness/foundation-string-extensions.swift new file mode 100644 index 0000000000000..b035fcbb1ba01 --- /dev/null +++ b/test/Interop/Cxx/objc-correctness/foundation-string-extensions.swift @@ -0,0 +1,11 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend %S/Inputs/SwiftTextCheckingResult.swift -I %S/Inputs -module-name SwiftTextCheckingResult -enable-objc-interop -emit-module -emit-module-path %t/SwiftTextCheckingResult.swiftmodule +// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -enable-objc-interop -enable-experimental-cxx-interop + +// REQUIRES: objc_interop + +import SwiftTextCheckingResult + +let _ = foo() + +// CHECK: @"$sSy10FoundationE20replacingOccurrences2of4with7options5rangeSSqd___qd_0_So22NSStringCompareOptionsVSnySS5IndexVGSgtSyRd__SyRd_0_r0_lF"