mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ClangImporter can now import non-public members as ofbe73254cdcand66c2e2c52b, but doing so triggers some latent ClangImporter bugs in projects that don't use or need those non-public members. This patch introduces a new experimental feature flag, ImportNonPublicCxxMembers, that guards against the importation of non-public members while we iron out those latent issues. Adopters of the SWIFT_PRIVATE_FILEID feature introduced inbdf22948cecan enable this flag to opt into importing private members they wish to access from Swift. rdar://145569473
67 lines
2.0 KiB
Swift
67 lines
2.0 KiB
Swift
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -cxx-interoperability-mode=default -enable-experimental-feature ImportNonPublicCxxMembers)
|
|
//
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: swift_feature_ImportNonPublicCxxMembers
|
|
|
|
import StdlibUnittest
|
|
import UsingBaseMembers
|
|
|
|
var UsingBaseTestSuite = TestSuite("Using Base Members")
|
|
|
|
UsingBaseTestSuite.test("PublicBasePrivateInheritance") {
|
|
var p = PublicBasePrivateInheritance()
|
|
expectEqual(123, p.publicGetter())
|
|
p.publicSetter(456)
|
|
expectEqual(456, p.publicGetter())
|
|
}
|
|
|
|
UsingBaseTestSuite.test("PublicBaseProtectedInheritance") {
|
|
var p = PublicBaseProtectedInheritance()
|
|
expectEqual(123, p.publicGetter())
|
|
p.publicSetter(987)
|
|
expectEqual(987, p.publicGetter())
|
|
}
|
|
|
|
UsingBaseTestSuite.test("PublicBaseUsingPrivateTypedef") {
|
|
var p = PublicBaseUsingPrivateTypedef()
|
|
expectEqual(123, p.publicGetter())
|
|
p.publicSetter(987)
|
|
expectEqual(987, p.publicGetter())
|
|
}
|
|
|
|
UsingBaseTestSuite.test("PublicBaseUsingPrivateUsingType") {
|
|
var p = PublicBaseUsingPrivateTypedef()
|
|
expectEqual(123, p.publicGetter())
|
|
p.publicSetter(987)
|
|
expectEqual(987, p.publicGetter())
|
|
}
|
|
|
|
UsingBaseTestSuite.test("UsingBaseConstructorWithParam") {
|
|
let p1 = UsingBaseConstructorWithParam(566 as Int32)
|
|
expectEqual(566, p1.value)
|
|
let p2 = UsingBaseConstructorWithParam(987 as UInt32)
|
|
expectEqual(987, p2.value)
|
|
}
|
|
|
|
UsingBaseTestSuite.test("UsingBaseConstructorEmpty") {
|
|
let p = UsingBaseConstructorEmpty()
|
|
expectEqual(456, p.value)
|
|
}
|
|
|
|
UsingBaseTestSuite.test("ProtectedMemberPrivateInheritance") {
|
|
let p = ProtectedMemberPrivateInheritance()
|
|
expectEqual(456, p.protectedGetter())
|
|
}
|
|
|
|
UsingBaseTestSuite.test("OperatorBasePrivateInheritance") {
|
|
let p = OperatorBasePrivateInheritance()
|
|
// FIXME: actually calling operator bool seems to currently be broken
|
|
// (although type-checking it is fine)
|
|
// expectTrue(Bool(fromCxx: p))
|
|
// expectTrue(Bool(fromCxx: !p))
|
|
expectEqual(456, p.pointee)
|
|
// expectEqual(789, p[789]) // FIXME: operator[] is currently broken
|
|
}
|
|
|
|
runAllTests()
|