Question to the stdlib owners: is there any specif...
# stdlib
o
Question to the stdlib owners: is there any specific reason why
with
is declared as
@IgnorableReturnValue
, but
context
is not? I am cleaning up my tests where I found nested `with`'s from the pre-context parameter times and now I get warnings about unused return values? I think, this should be treated the same way as
with
was, so there's an annotation missing on
context
. Any thoughts?
d
Not an answer but just a side note that nested
with
seems like a code smell so I would lint against that. ChatGPT does a good job of explaining the hazards of this pattern and why it should be avoided.
f
Sorry for the late reply - it will be fixed in Kotlin 2.5.0 (youtrack.jetbrains.com/issue/KT-83890). Both
with
and
context
will not be annotated with
@IgnorableReturnValue
, but instead they will propagate ignobility from the last expression in the block (
returnsResultOf
contract).
👍 1