Skip to content

Commit eedae18

Browse files
authored
Merge pull request #78656 from swiftlang/egorzhdan/6.1-os-logger
🍒[cxx-interop] Workaround name lookup issues with `namespace os`
2 parents fa5461d + 3a8ed89 commit eedae18

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,14 @@ namespace {
11471147
// Do not import namespace declarations marked as 'swift_private'.
11481148
if (decl->hasAttr<clang::SwiftPrivateAttr>())
11491149
return nullptr;
1150+
// Workaround for os module declaring `namespace os` on Darwin, causing
1151+
// name lookup issues. That namespace only declares utility functions that
1152+
// are not supposed to be used from Swift, so let's just not import the
1153+
// namespace (rdar://119044493).
1154+
if (decl->getIdentifier() && decl->getName() == "os" &&
1155+
decl->getOwningModule() &&
1156+
decl->getOwningModule()->getTopLevelModuleName() == "os")
1157+
return nullptr;
11501158
// If this is a top-level namespace, don't put it in the module we're
11511159
// importing, put it in the "__ObjC" module that is implicitly imported.
11521160
if (!decl->getParent()->isNamespace())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: OS=macosx
5+
6+
import os
7+
8+
var _: os.Logger! = nil

0 commit comments

Comments
 (0)