@@ -4579,7 +4579,8 @@ namespace {
4579
4579
/* genericParams=*/ nullptr , bodyParams,
4580
4580
resultTy, async, throws, dc, decl);
4581
4581
4582
- result->setAccess (getOverridableAccessLevel (dc));
4582
+ result->setAccess (decl->isDirectMethod () ? AccessLevel::Public
4583
+ : getOverridableAccessLevel (dc));
4583
4584
4584
4585
// Optional methods in protocols.
4585
4586
if (decl->getImplementationControl () == clang::ObjCMethodDecl::Optional &&
@@ -5331,8 +5332,9 @@ namespace {
5331
5332
}
5332
5333
5333
5334
auto type = importedType.getType ();
5334
- auto result = Impl.createDeclWithClangNode <VarDecl>(decl,
5335
- getOverridableAccessLevel (dc),
5335
+ const auto access = decl->isDirectProperty () ? AccessLevel::Public
5336
+ : getOverridableAccessLevel (dc);
5337
+ auto result = Impl.createDeclWithClangNode <VarDecl>(decl, access,
5336
5338
/* IsStatic*/ decl->isClassProperty (), VarDecl::Introducer::Var,
5337
5339
Impl.importSourceLoc (decl->getLocation ()), name, dc);
5338
5340
result->setInterfaceType (type);
@@ -7023,7 +7025,13 @@ SwiftDeclConverter::importSubscript(Decl *decl,
7023
7025
bodyParams, decl->getLoc (),
7024
7026
elementTy, dc,
7025
7027
getter->getClangNode ());
7026
- const auto access = getOverridableAccessLevel (dc);
7028
+
7029
+ bool IsObjCDirect = false ;
7030
+ if (auto objCDecl = dyn_cast<clang::ObjCMethodDecl>(getter->getClangDecl ())) {
7031
+ IsObjCDirect = objCDecl->isDirectMethod ();
7032
+ }
7033
+ const auto access = IsObjCDirect ? AccessLevel::Public
7034
+ : getOverridableAccessLevel (dc);
7027
7035
subscript->setAccess (access);
7028
7036
subscript->setSetterAccess (access);
7029
7037
@@ -7877,10 +7885,13 @@ void ClangImporter::Implementation::importAttributes(
7877
7885
7878
7886
if (auto method = dyn_cast<clang::ObjCMethodDecl>(ClangDecl)) {
7879
7887
if (method->isDirectMethod () && !AnyUnavailable) {
7880
- auto attr = AvailableAttr::createPlatformAgnostic (
7881
- C, " " , " " , PlatformAgnosticAvailabilityKind::UnavailableInSwift);
7882
- MappedDecl->getAttrs ().add (attr);
7883
- AnyUnavailable = true ;
7888
+ assert (isa<AbstractFunctionDecl>(MappedDecl) &&
7889
+ " objc_direct declarations are expected to be an AbstractFunctionDecl" );
7890
+ MappedDecl->getAttrs ().add (new (C) FinalAttr (/* IsImplicit=*/ true ));
7891
+ if (auto accessorDecl = dyn_cast<AccessorDecl>(MappedDecl)) {
7892
+ auto attr = new (C) FinalAttr (/* isImplicit=*/ true );
7893
+ accessorDecl->getStorage ()->getAttrs ().add (attr);
7894
+ }
7884
7895
}
7885
7896
}
7886
7897
0 commit comments