-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++Feature: Interoperability with C++
Description
Description
I have two Swift modules/pods: FirstPod
and SecondPod
. Both use C++ interop, and both call Swift classes/functions from C++.
FirstPod
has this class:
open class First { … }
SecondPod
has this class:
import FirstPod
public class Second: First { … }
Because Second
inherits from First
, the SecondPod-Swift.h
header file produces build errors since it cannot find Second
's base class (First
) as that is nowhere included:
- Unknown class name 'First'
Code:
class SWIFT_SYMBOL("s:13Second06FirstC") Second : public FirstPod::First {
public:
using First::First;
using First::operator=;
static SWIFT_INLINE_THUNK Second init() SWIFT_SYMBOL("s:13Second06FirstCACycfc");
protected:
SWIFT_INLINE_THUNK Second(void * _Nonnull ptr) noexcept : First(ptr) {}
private:
friend class _impl::_impl_Second;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
typedef char $s13Second06FirstCD;
static inline constexpr $s13Second06FirstCD __swift_mangled_name = 0;
#pragma clang diagnostic pop
#pragma clang diagnostic pop
};
- Forward-declaring doesn't help either, since it needs a concrete type for a base class.
- Including
FirstPod-Swift.h
before I includeSecondPod-Swift.h
doesn't work either because (as far as I know) you cannot include the-Swift.h
header of another module inside your module.
I'm out of ideas at this point. Any suggestions?
Reproduction
public class First { … }
import FirstPod
public class Second: First { … }
…then try calling Second
from within a C++ file in SecondPod
Expected behavior
I expect there to be some sort of forward-declaration mechanism, or a void*
boxing mechanism to ensure foreign types can be handled.
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++Feature: Interoperability with C++