9db3440e72
Use 'expectedType' (when present) as an explicit type argument for a special construct call. Unfortunately, this approach can't be used for elvis due to other elvis-related inference hacks. Fixes KT-10807, KT-10811. This also affects KT-6189: now we can infer proper type for 'if'. If type inference for special call failed, and we found no type errors in sub-expressions, report TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT error. This (and the hack above) fixes KT-10809: code no longer compiles.
17 lines
420 B
Kotlin
Vendored
17 lines
420 B
Kotlin
Vendored
import java.util.*
|
|
import kotlin.comparisons.compareBy
|
|
import kotlin.comparisons.nullsLast
|
|
|
|
class Foo(val a: String, val b: Int)
|
|
|
|
fun getComp(): Comparator<Foo?> =
|
|
when {
|
|
else -> nullsLast(compareBy({ it.a }, { it.b }))
|
|
}
|
|
|
|
fun getCompInverted(): Comparator<Foo?> =
|
|
nullsLast(
|
|
when {
|
|
else -> compareBy({ it.a }, { it.b })
|
|
}
|
|
) |