Skip to content

Commit

Permalink
Merge pull request #78634 from swiftlang/egorzhdan/os-logger
Browse files Browse the repository at this point in the history
[cxx-interop] Workaround name lookup issues with `namespace os`
  • Loading branch information
egorzhdan authored Jan 15, 2025
2 parents 8c07ca9 + 430809d commit dd11207
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,14 @@ namespace {
// Do not import namespace declarations marked as 'swift_private'.
if (decl->hasAttr<clang::SwiftPrivateAttr>())
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())
Expand Down
8 changes: 8 additions & 0 deletions test/Interop/Cxx/objc-correctness/os-logger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %target-swift-frontend -typecheck -verify -I %S/Inputs -cxx-interoperability-mode=default %s

// REQUIRES: objc_interop
// REQUIRES: VENDOR=apple

import os

var _: os.Logger! = nil

0 comments on commit dd11207

Please sign in to comment.