Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🍒[cxx-interop] Workaround name lookup issues with namespace os #78656

Open
wants to merge 2 commits into
base: release/6.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,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