@@ -2090,10 +2090,6 @@ getForeignRepresentable(Type type, ForeignLanguage language,
2090
2090
2091
2091
ASTContext &ctx = nominal->getASTContext ();
2092
2092
2093
- // If the type is @objc, it is trivially representable in Objective-C.
2094
- if (nominal->isObjC () && language == ForeignLanguage::ObjectiveC)
2095
- return { ForeignRepresentableKind::Trivial, nullptr };
2096
-
2097
2093
// Unmanaged<T> can be trivially represented in Objective-C if T
2098
2094
// is trivially represented in Objective-C.
2099
2095
if (language == ForeignLanguage::ObjectiveC &&
@@ -2113,14 +2109,17 @@ getForeignRepresentable(Type type, ForeignLanguage language,
2113
2109
2114
2110
// If the type was imported from Clang, check whether it is
2115
2111
// representable in the requested language.
2116
- if (nominal->hasClangNode ()) {
2112
+ if (nominal->hasClangNode () || nominal-> isObjC () ) {
2117
2113
switch (language) {
2118
2114
case ForeignLanguage::C:
2119
2115
// Imported structs and enums are trivially representable in C.
2120
2116
// FIXME: This is not entirely true; we need to check that
2121
2117
// all of the exposed parts are representable in C.
2122
- if (isa<StructDecl>(nominal) || isa<EnumDecl>(nominal))
2118
+ if (isa<StructDecl>(nominal) || isa<EnumDecl>(nominal)) {
2119
+ if (wasOptional)
2120
+ break ;
2123
2121
return { ForeignRepresentableKind::Trivial, nullptr };
2122
+ }
2124
2123
2125
2124
// Imported classes and protocols are not.
2126
2125
if (isa<ClassDecl>(nominal) || isa<ProtocolDecl>(nominal))
@@ -2129,7 +2128,10 @@ getForeignRepresentable(Type type, ForeignLanguage language,
2129
2128
llvm_unreachable (" Unhandled nominal type declaration" );
2130
2129
2131
2130
case ForeignLanguage::ObjectiveC:
2132
- // Anything Clang imported is trivially representable in Objective-C.
2131
+ if (isa<StructDecl>(nominal) || isa<EnumDecl>(nominal))
2132
+ if (wasOptional)
2133
+ break ;
2134
+
2133
2135
return { ForeignRepresentableKind::Trivial, nullptr };
2134
2136
}
2135
2137
}
0 commit comments