Skip to content

Commit 2534f41

Browse files
authored
Ignore unused jboolean (#482)
1 parent c6184a3 commit 2534f41

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+NativeTranslation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ extension JNISwift2JavaGenerator {
10371037
printer.print("environment = try! JavaVirtualMachine.shared().environment()")
10381038
let inner = nativeFunctionSignature.result.conversion.render(&printer, "swiftResult$")
10391039
if swiftFunctionResultType.isVoid {
1040-
printer.print("environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: nil)])")
1040+
printer.print("_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: nil)])")
10411041
} else {
10421042
let result: String
10431043
if nativeFunctionSignature.result.javaType.requiresBoxing {
@@ -1047,7 +1047,7 @@ extension JNISwift2JavaGenerator {
10471047
result = inner
10481048
}
10491049

1050-
printer.print("environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: \(result))])")
1050+
printer.print("_ = environment.interface.CallBooleanMethodA(environment, globalFuture, \(completeMethodID), [jvalue(l: \(result))])")
10511051
}
10521052
}
10531053

@@ -1069,7 +1069,7 @@ extension JNISwift2JavaGenerator {
10691069
"""
10701070
let catchEnvironment = try! JavaVirtualMachine.shared().environment()
10711071
let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)])
1072-
catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, \(completeExceptionallyMethodID), [jvalue(l: exception)])
1072+
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, \(completeExceptionallyMethodID), [jvalue(l: exception)])
10731073
"""
10741074
)
10751075
}
@@ -1111,4 +1111,4 @@ extension JNISwift2JavaGenerator {
11111111
}
11121112
}
11131113
}
1114-
}
1114+
}

Tests/JExtractSwiftTests/JNI/JNIAsyncTests.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct JNIAsyncTests {
7171
}
7272
let swiftResult$ = await SwiftModule.asyncVoid()
7373
environment = try! JavaVirtualMachine.shared().environment()
74-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
74+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
7575
}
7676
}
7777
#endif
@@ -84,7 +84,7 @@ struct JNIAsyncTests {
8484
}
8585
let swiftResult$ = await SwiftModule.asyncVoid()
8686
environment = try! JavaVirtualMachine.shared().environment()
87-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
87+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
8888
}
8989
}
9090
}
@@ -146,12 +146,12 @@ struct JNIAsyncTests {
146146
do {
147147
let swiftResult$ = await try SwiftModule.async()
148148
environment = try! JavaVirtualMachine.shared().environment()
149-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
149+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
150150
}
151151
catch {
152152
let catchEnvironment = try! JavaVirtualMachine.shared().environment()
153153
let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)])
154-
catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
154+
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
155155
}
156156
}
157157
}
@@ -166,12 +166,12 @@ struct JNIAsyncTests {
166166
do {
167167
let swiftResult$ = await try SwiftModule.async()
168168
environment = try! JavaVirtualMachine.shared().environment()
169-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
169+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: nil)])
170170
}
171171
catch {
172172
let catchEnvironment = try! JavaVirtualMachine.shared().environment()
173173
let exception = catchEnvironment.interface.NewObjectA(catchEnvironment, _JNIMethodIDCache.Exception.class, _JNIMethodIDCache.Exception.constructWithMessage, [String(describing: error).getJValue(in: catchEnvironment)])
174-
catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
174+
_ = catchEnvironment.interface.CallBooleanMethodA(catchEnvironment, globalFuture, _JNIMethodIDCache.CompletableFuture.completeExceptionally, [jvalue(l: exception)])
175175
}
176176
}
177177
}
@@ -234,7 +234,7 @@ struct JNIAsyncTests {
234234
let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment))
235235
environment = try! JavaVirtualMachine.shared().environment()
236236
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNIValue(in: environment), in: environment)
237-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
237+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
238238
}
239239
}
240240
#endif // end of swift(>=6.2)
@@ -248,7 +248,7 @@ struct JNIAsyncTests {
248248
let swiftResult$ = await SwiftModule.async(i: Int64(fromJNI: i, in: environment))
249249
environment = try! JavaVirtualMachine.shared().environment()
250250
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(swiftResult$.getJNIValue(in: environment), in: environment)
251-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
251+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
252252
}
253253
}
254254
return
@@ -328,7 +328,7 @@ struct JNIAsyncTests {
328328
result$.initialize(to: swiftResult$)
329329
let resultBits$ = Int64(Int(bitPattern: result$))
330330
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNIValue(in: environment), in: environment)
331-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
331+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
332332
}
333333
}
334334
#endif
@@ -345,7 +345,7 @@ struct JNIAsyncTests {
345345
result$.initialize(to: swiftResult$)
346346
let resultBits$ = Int64(Int(bitPattern: result$))
347347
let boxedResult$ = SwiftJavaRuntimeSupport._JNIBoxedConversions.box(resultBits$.getJNIValue(in: environment), in: environment)
348-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
348+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: boxedResult$)])
349349
}
350350
}
351351
return
@@ -402,7 +402,7 @@ struct JNIAsyncTests {
402402
deferEnvironment.interface.DeleteGlobalRef(deferEnvironment, s)
403403
}
404404
...
405-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: swiftResult$.getJNIValue(in: environment))])
405+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.CompletableFuture.complete, [jvalue(l: swiftResult$.getJNIValue(in: environment))])
406406
...
407407
}
408408
"""
@@ -463,11 +463,11 @@ struct JNIAsyncTests {
463463
...
464464
var task: Task<Void, Never>? = nil
465465
...
466-
environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [jvalue(l: boxedResult$)])
466+
_ = environment.interface.CallBooleanMethodA(environment, globalFuture, _JNIMethodIDCache.SimpleCompletableFuture.complete, [jvalue(l: boxedResult$)])
467467
...
468468
}
469469
"""
470470
]
471471
)
472472
}
473-
}
473+
}

0 commit comments

Comments
 (0)