Streams collector use in Kotlin code


I am likely being very stupid in not realizing how to get round this issue. The code:

fun usingStreamSequence(l:List<Int>):List<Int> {

give the following error on the collect call:

Type inference failed. Expected type mismatch: inferred type is (MutableList<in Int!>..List<Any?>?) but List<Int> was expected

I am using IDEA 2016.02 EAP with the Kotlin 1.1.0-dev plugin but the project is a Gradle one and uses the 1.0.2 version of Kotlin. All on Debian Sid.


It’s a known problem with the type inference of Stream.collect method:
Currently you have to specify type of Collectors.toList explicitly as a workaround.


Ah, OK. I will do that. Thanks for letting me know quickly, that is much appreciated.