- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.6k
Milestone
Description
JUnit Jupiter 6.0.0 added @Nullable annotations.
I believe TypedArgumentConverter is missing such an annotation for the return type of its protected convert method.
Currently the signature is:
protected abstract T convert(@Nullable S source) throws ArgumentConversionException;I believe this should be:
protected abstract @Nullable T convert(@Nullable S source) throws ArgumentConversionException;This would simplify writing Kotlin code using TypedArgumentConverter.
The following Kotlin code does not compile against JUnit Jupiter 6.0.0:
class DummyConverter : TypedArgumentConverter<String, String>(String::class.java, String::class.java) {
    override fun convert(source: String?): String? = source
}I believe that with an additional @Nullable annotation as shown above this code would compile.
The current workaround in Kotlin is somewhat ugly as it requires an unchecked cast:
class DummyConverter : TypedArgumentConverter<String, String?>(String::class.java, String::class.java as Class<String?>) {
    override fun convert(source: String?): String? = source
}