Skip to content

Commit 50c3206

Browse files
committed
Add document for typeErasedResultBound param
1 parent 8c048cd commit 50c3206

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Sources/SwiftJava/Macros.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,19 @@ public macro JavaStaticField(_ javaFieldName: String? = nil, isFinal: Bool = fal
134134
///
135135
/// In order to mark a generic return type you must indicate it to the @JavaMethod macro like this:
136136
/// ```swift
137-
/// // Java: class Test<T> { public <T> get(); }
137+
/// // Java: class Test<T> { public T get(); }
138138
/// @JavaMethod(typeErasedResult: "T!")
139139
/// func get() -> T!
140140
/// ```
141141
/// This allows the macro to form a call into the get() method, which at runtime, will have an `java.lang.Object`
142142
/// returning method signature, and then, convert the result to the expected `T` type on the Swift side.
143+
///
144+
/// If the return type is a wildcard type, specify the bound type instead of `java.lang.Object`:
145+
/// ```swift
146+
/// // Java: class Test<T extends Animal> { public T get(); }
147+
/// @JavaMethod(typeErasedResult: "T!", typeErasedResultBound: Animal?.self)
148+
/// func get() -> T!
149+
/// ```
143150
@attached(body)
144151
public macro JavaMethod<ResultBoundType: JavaValue>(
145152
_ javaMethodName: String? = nil,

0 commit comments

Comments
 (0)