I used Android studio's conversion tool to convert existing java test class.
I am getting this error :
only classes are allowed on the left hand side of a class literal
Here is the test case used :
Java
doAnswer(answerVoid(
(OnDataListListener<List<BEntity>> myCallback) -> myCallback.onSuccess(mList))).when(
mInteractor).performGetBList(any(OnDataListListener.class), anyBoolean());
Kotlin
doAnswer(answerVoid { listener: OnDataListListener<List<BEntity>> ->
listener.onSuccess(
emptyList())
}).`when`<DragonInteractor>(mInteractor)
.performGetBList(any<OnDataListListener>(OnDataListListener<*>::class.java),
anyBoolean())
So how to use generic params in this case? Thanks.
Just use OnDataListListener::class.java
.
The reason why the angle brackets are not required (and not allowed) in a class reference expresison is that class references are completely agnostic of generics, there are no different class references for generic specializations of a class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With