@@ -4537,7 +4537,8 @@ namespace {
4537
4537
bodyParams, resultTy,
4538
4538
async, throws, dc, decl);
4539
4539
4540
- result->setAccess (getOverridableAccessLevel (dc));
4540
+ result->setAccess (decl->isDirectMethod () ? AccessLevel::Public
4541
+ : getOverridableAccessLevel (dc));
4541
4542
4542
4543
// Optional methods in protocols.
4543
4544
if (decl->getImplementationControl () == clang::ObjCMethodDecl::Optional &&
@@ -5289,8 +5290,9 @@ namespace {
5289
5290
}
5290
5291
5291
5292
auto type = importedType.getType ();
5292
- auto result = Impl.createDeclWithClangNode <VarDecl>(decl,
5293
- getOverridableAccessLevel (dc),
5293
+ const auto access = decl->isDirectProperty () ? AccessLevel::Public
5294
+ : getOverridableAccessLevel (dc);
5295
+ auto result = Impl.createDeclWithClangNode <VarDecl>(decl, access,
5294
5296
/* IsStatic*/ decl->isClassProperty (), VarDecl::Introducer::Var,
5295
5297
Impl.importSourceLoc (decl->getLocation ()), name, dc);
5296
5298
result->setInterfaceType (type);
@@ -6981,7 +6983,13 @@ SwiftDeclConverter::importSubscript(Decl *decl,
6981
6983
bodyParams, decl->getLoc (),
6982
6984
elementTy, dc,
6983
6985
getter->getClangNode ());
6984
- const auto access = getOverridableAccessLevel (dc);
6986
+
6987
+ bool IsObjCDirect = false ;
6988
+ if (auto objCDecl = dyn_cast<clang::ObjCMethodDecl>(getter->getClangDecl ())) {
6989
+ IsObjCDirect = objCDecl->isDirectMethod ();
6990
+ }
6991
+ const auto access = IsObjCDirect ? AccessLevel::Public
6992
+ : getOverridableAccessLevel (dc);
6985
6993
subscript->setAccess (access);
6986
6994
subscript->setSetterAccess (access);
6987
6995
@@ -7835,10 +7843,13 @@ void ClangImporter::Implementation::importAttributes(
7835
7843
7836
7844
if (auto method = dyn_cast<clang::ObjCMethodDecl>(ClangDecl)) {
7837
7845
if (method->isDirectMethod () && !AnyUnavailable) {
7838
- auto attr = AvailableAttr::createPlatformAgnostic (
7839
- C, " " , " " , PlatformAgnosticAvailabilityKind::UnavailableInSwift);
7840
- MappedDecl->getAttrs ().add (attr);
7841
- AnyUnavailable = true ;
7846
+ assert (isa<AbstractFunctionDecl>(MappedDecl) &&
7847
+ " objc_direct declarations are expected to be an AbstractFunctionDecl" );
7848
+ MappedDecl->getAttrs ().add (new (C) FinalAttr (/* IsImplicit=*/ true ));
7849
+ if (auto accessorDecl = dyn_cast<AccessorDecl>(MappedDecl)) {
7850
+ auto attr = new (C) FinalAttr (/* isImplicit=*/ true );
7851
+ accessorDecl->getStorage ()->getAttrs ().add (attr);
7852
+ }
7842
7853
}
7843
7854
}
7844
7855
0 commit comments