Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,9 @@ extension LoweredFunctionSignature {

var loweredCDecl = try! FunctionDeclSyntax(
"""
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl(\(literal: cName))
public func \(raw: cName)(\(raw: cdeclParams))\(raw: returnClause) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ struct SwiftThunkTranslator {

return
"""
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl("\(raw: funcName)")
public func \(raw: funcName)() -> UnsafeMutableRawPointer /* Any.Type */ {
return unsafeBitCast(\(raw: nominal.swiftNominal.qualifiedName).self, to: UnsafeMutableRawPointer.self)
Expand Down Expand Up @@ -285,6 +288,9 @@ struct SwiftThunkTranslator {

let copyBytesThunk: DeclSyntax =
"""
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl("\(raw: thunkName)")
public func \(raw: thunkName)(
selfPointer: UnsafeRawPointer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ extension JNISwift2JavaGenerator {
#if compiler(>=6.3)
@used
#endif
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl("\(cName)")
public func \(cName)(\(thunkParameters.joined(separator: ", ")))\(thunkReturnType)
"""
Expand Down
11 changes: 9 additions & 2 deletions Tests/JExtractSwiftTests/Asserts/LoweringAssertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import SwiftJavaConfigurationShared
import SwiftSyntax
import Testing

private let thunkDiagnoseAttribute = """
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif

"""

/// Assert that the lowering of the function function declaration to a @_cdecl
/// entrypoint matches the expected form.
func assertLoweredFunction(
Expand Down Expand Up @@ -79,7 +86,7 @@ func assertLoweredFunction(
)

#expect(
loweredCDecl.description == expectedCDecl.description,
loweredCDecl.description == thunkDiagnoseAttribute + expectedCDecl.description,
sourceLocation: Testing.SourceLocation(
fileID: fileID,
filePath: filePath,
Expand Down Expand Up @@ -147,7 +154,7 @@ func assertLoweredVariableAccessor(
)

#expect(
loweredCDecl?.description == expectedCDecl?.description,
loweredCDecl?.description == expectedCDecl.map { thunkDiagnoseAttribute + $0.description },
sourceLocation: Testing.SourceLocation(
fileID: fileID,
filePath: filePath,
Expand Down
10 changes: 8 additions & 2 deletions Tests/JExtractSwiftTests/JNI/JNICDeclAttributesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Testing
struct JNICDeclAttributesTests {

@Test
func globalFunc_hasUsedAttribute() throws {
func globalFunc_hasThunkAttributes() throws {
try assertOutput(
input: "public func hello()",
.jni,
Expand All @@ -29,6 +29,9 @@ struct JNICDeclAttributesTests {
#if compiler(>=6.3)
@used
#endif
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl("Java_com_example_swift_SwiftModule__00024hello__")
...
"""
Expand All @@ -37,7 +40,7 @@ struct JNICDeclAttributesTests {
}

@Test
func globalFuncWithArgs_hasUsedAttribute() throws {
func globalFuncWithArgs_hasThunkAttributes() throws {
try assertOutput(
input: "public func add(a: Int64, b: Int64) -> Int64",
.jni,
Expand All @@ -47,6 +50,9 @@ struct JNICDeclAttributesTests {
#if compiler(>=6.3)
@used
#endif
#if compiler(>=6.4)
@diagnose(DeprecatedDeclaration, as: ignored)
#endif
@_cdecl("Java_com_example_swift_SwiftModule__00024add__JJ")
...
"""
Expand Down
Loading