Did I encounter a bug? consider the following code...
# announcements
m
Did I encounter a bug? consider the following code:
Copy code
typealias Point = Pair<Int, Int>
val (axis1, axis2, pointConstruct) = when(horizontal){
    true -> Triple(0..height, 0..width, {a1, a2 -> Point(a1, a2)})
    false -> Triple(0..width, 0..height, {a1, a2 -> Point(a2, a1)})
}
Instead of telling me:
Type cannot be infered
on a1,a2 in any of both lambdas, it simply states that Point is unreachable code. Alongside; it states that pointConstruct is a
(Nothing, Nothing) -> Point
function simply declaring:
Copy code
val pointConstruct = {a1, a2 -> Point(a1, a2)}
will correctly tell me that a1 and a2 cannot be infered. Why does it infer a
(Nothing, Nothing) -> Point
in the deconstructed lamba, but a compile error on the single line one?
k
Seems like a bug to me. Very weird indeed. Adding
:Int
the the first
a1
makes the second one also an
Int
but not the other way around
a
Can you please file an issue on http://kotl.in/issue with a self-contained code sample to reproduce? Thanks!
m
I just did. Visible here: https://youtrack.jetbrains.com/issue/KT-38246 🙂
🙏 1