diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 1aaf01b9320b8..16cc1e3116c98 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -1147,6 +1147,14 @@ namespace { // Do not import namespace declarations marked as 'swift_private'. if (decl->hasAttr()) return nullptr; + // Workaround for os module declaring `namespace os` on Darwin, causing + // name lookup issues. That namespace only declares utility functions that + // are not supposed to be used from Swift, so let's just not import the + // namespace (rdar://119044493). + if (decl->getIdentifier() && decl->getName() == "os" && + decl->getOwningModule() && + decl->getOwningModule()->getTopLevelModuleName() == "os") + return nullptr; // If this is a top-level namespace, don't put it in the module we're // importing, put it in the "__ObjC" module that is implicitly imported. if (!decl->getParent()->isNamespace()) diff --git a/test/Interop/Cxx/objc-correctness/os-logger.swift b/test/Interop/Cxx/objc-correctness/os-logger.swift new file mode 100644 index 0000000000000..62115c47f120b --- /dev/null +++ b/test/Interop/Cxx/objc-correctness/os-logger.swift @@ -0,0 +1,8 @@ +// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s + +// REQUIRES: objc_interop +// REQUIRES: OS=macosx + +import os + +var _: os.Logger! = nil