Reputation: 2495
Example Kotlin class:
class Example {
private lateinit var creator: (Unit) -> String
}
Equivalent in java will be
class Example {
Function1<? super Unit, ? super String> creator
}
How can I annotate field creator to avoid using of wildcards?
Upvotes: 1
Views: 482
Reputation: 10106
You can remove wildcards by using @JvmSuppressWildcards
:
lateinit var creator: (@JvmSuppressWildcards Unit) -> @JvmSuppressWildcards String
By the way your code won't generete wildcards, so following code is perfectly valid without any annotations:
new Example().setCreator(new Function1<Unit, String>() {
@Override
public String invoke(Unit unit) {
return "Test";
}
});
Upvotes: 1