mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`. MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized. rdar://114282353 / resolves https://github.com/apple/swift/issues/68068
34 lines
1.1 KiB
Swift
34 lines
1.1 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=UsingBaseMembers -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift | %FileCheck %s
|
|
|
|
// CHECK: struct PublicBase {
|
|
// CHECK-NEXT: init()
|
|
// CHECK-NEXT: func publicGetter() -> Int32
|
|
// CHECK-NEXT: mutating func publicSetter(_ v: Int32)
|
|
// CHECK-NEXT: func notExposed()
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: struct PublicBasePrivateInheritance {
|
|
// CHECK-NEXT: init()
|
|
// CHECK-NEXT: func publicGetter() -> Int32
|
|
// CHECK-NEXT: mutating func publicSetter(_ v: Int32)
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: struct PublicBaseProtectedInheritance {
|
|
// CHECK-NEXT: init()
|
|
// CHECK-NEXT: func publicGetter() -> Int32
|
|
// CHECK-NEXT: mutating func publicSetter(_ v: Int32)
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: struct UsingBaseConstructorWithParam {
|
|
// CHECK-NEXT: init(_: IntBox)
|
|
// CHECK-NEXT: init(_: UInt32)
|
|
// CHECK-NEXT: init(_: Int32)
|
|
// CHECK-NEXT: var value: Int32
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: struct UsingBaseConstructorEmpty {
|
|
// CHECK-NEXT: init()
|
|
// CHECK-NEXT: init(_: Empty)
|
|
// CHECK-NEXT: var value: Int32
|
|
// CHECK-NEXT: }
|