smallrye-mutiny icon indicating copy to clipboard operation
smallrye-mutiny copied to clipboard

Kotlin types are lost on specific operations

Open MartinX3 opened this issue 2 years ago • 3 comments

With kotlin and smallyre sometimes I need to declare the type again.

Additional details

Examples:

  • .transformToMulti { fetch(it.bananas).onItem().disjoint<Banana>() } Without <Banana> it doesn't know that I fetch the Bananas.
  • .call { it -> if (it.type?.entityType == Apple) serviceApple.updateBy(it) else createUniFrom().nullItem<Apple>() } Without <Apple> it doesn't know that it should return a nullItem with this type. But shouldn't it know it already, because I return an Uni<Apple> in the true case? PS: nullItem<Void> and nullItem<Unit> are working too, which confuses me more. There is .voidItem(), but that I would otherwise need to declare the type confuses me. Maybe the java code of smallrye confuses kotlin?

Maybe we need kotlin classes as a layer in smallrye which optimize the kotlin compatibility? As far as I know the Quarkus Framework uses this approach.

PS: I like the word confusing

MartinX3 avatar May 10 '22 15:05 MartinX3

Like the idea and would love to investigate, unfortunately, I'm blocked for the next month. @MartinX3 how about meet at https://www.cloudland.org/ and discuss in person? ;)

heubeck avatar May 13 '22 16:05 heubeck

@heubeck Sadly it's too expensive for me and I use Mutiny only for my job. I don't use it in my volunteer tasks and my studies, so I also don't have time as well.

I found a new issue It needs the type for the mapping function. So .map(List<Double>::average) and .map { it.average() } are working, but .map(::average) throws an error.

    fun findAverageScoreByA(id: UUID): Uni<Double> =
        stream("b.aId", id).group().by { it.category.name }
            .onItem().transformToUniAndMerge { it.collect().asList() }.map { it.map(b::score).average() }
            .collect().asList().map(List<Double>::average)

MartinX3 avatar Jun 28 '22 14:06 MartinX3

Thanks @MartinX3 , no issue, my own organization has a way to go as well in regards of official support on OSS contributions.

Just keep reporting, will care as soon as possible.

heubeck avatar Jul 06 '22 09:07 heubeck