simon.vergauwen
03/07/2023, 6:26 PMbod
03/07/2023, 6:54 PMval
can be initialized in the lambda. +1 runCatching
should/could have used it (unless I'm missing something). Where do you see the unreachable code warning?simon.vergauwen
03/07/2023, 6:58 PMrunCatching
, or it results in a false positive. I know the benefits of using it, but we're getting false-negatives all over after adding it to Arrow. More context in Arrow.bod
03/07/2023, 7:03 PMcontract
or notsimon.vergauwen
03/07/2023, 7:05 PMEXACTLTY_ONCE
contract. It's also been reported by other people (assuming using different versions of IDEA).bod
03/07/2023, 7:07 PMsimon.vergauwen
03/07/2023, 7:10 PMkotlin.runCatching
without EXACTLY_ONCE
you cannot initialise val
.bod
03/07/2023, 7:14 PMrunCatching
existed prior to the contracts being introduced and they were just never added - but I'm just conjecturingfranztesca
03/08/2023, 12:06 AMval x: String
runCatching {
if (1+1==2) throw Exception()
x = "42"
}
println(x)
If runCatching had EXACTLY_ONCE, this code would compile with no problem, but x would not be initialized when the println statement is reached.
In general, if your function catches any throwable of the block, it is not safe to add EXACTLY_ONCE AFAIS.