4ab6b6954d
Inferred type of receiver of orElse is Optional<T & Any> Generic descriptor is orElse(E!): E! Substituted descriptor is orElse(T): T , and that is the problem. Seems that E! => (T & Any)! gets expanded to just T or T & Any , however it should be expanded to (T & Any) .. (T & Any)? => T & Any .. T & Any T & Any is NotNullTypeParameter(T) The problem is that (T & Any)? is expanded to T & Any, that is seems to be wrong. #KT-15236 Fixed
8 lines
252 B
Kotlin
Vendored
8 lines
252 B
Kotlin
Vendored
import java.util.*
|
|
import java.util.stream.Stream
|
|
|
|
fun <T> Stream<T>?.getIfSingle() =
|
|
this?.map { Optional.ofNullable(it) }
|
|
?.reduce(Optional.empty()) { _, _ -> Optional.empty() }
|
|
?.orElse(null) // <<---- should not be an error
|