Mikael Alfredsson
02/20/2020, 9:32 AMMikael Alfredsson
02/20/2020, 9:34 AMfalse since all variables are -1 and the last evaluation tells me that it actually should be falsespand
02/20/2020, 9:52 AMMikael Alfredsson
02/20/2020, 9:53 AMspand
02/20/2020, 9:54 AMMikael Alfredsson
02/20/2020, 9:54 AMKiryushin Andrey
02/20/2020, 11:02 AMit?.id ?: -1 expression resolves to the value of Int type when used as a part of a bigger expressionMikael Alfredsson
02/20/2020, 11:04 AMif (1L== 1) will return a compiler error.spand
02/20/2020, 11:53 AM1L == (-1 as Number) which compiles also.Kiryushin Andrey
02/20/2020, 12:16 PMAny type for the expression like it?.id ?: -1 in case left-hand part is inferred to be other than Int - this would make this pitfall more visible (and btw if you replace -1 with a reference to variable of Int type, the actual type inferred for the expression would really be Any)
• or emit the run-time conversion of the right-hand numeric constant to Long into the generated bytecode.