Files
swift-mirror/test/Interop/SwiftToCxx/expose-attr/hidden-decls.swift
Gabor Horvath 7ac9a81b1e [cxx-interop] Add attribute to hide Swift declarations from interop
This can help work around problems when the names of a C++ declaration
and a Swift declaration would collide, or to temporarily work around
compiler bugs.

rdar://152838988&140802127&158843666
2025-09-01 12:29:34 +01:00

34 lines
767 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -module-name SwiftPrivate -clang-header-expose-decls=all-public -typecheck -verify -emit-clang-header-path %t/swiftprivate.h
// RUN: %FileCheck %s < %t/swiftprivate.h
// RUN: %check-interop-cxx-header-in-clang(%t/swiftprivate.h -DSWIFT_CXX_INTEROP_HIDE_STL_OVERLAY)
public struct Exposed {
public var x: Int
@_expose(!Cxx)
public var notExposedField: Int
}
@_expose(!Cxx)
public struct NotExposed {
public var x: Int
}
extension NotExposed {
func notExposed() {}
}
@_expose(!Cxx)
public func NotExposedfunction() {}
@MainActor
@_expose(!Cxx)
public class UnavailableClass {
}
// CHECK-NOT: NotExposed
// CHECK-NOT: notExposed
// CHECK: Exposed
// CHECK-NOT: UnavailableClass