Another thing to add: it seems like variations of ...
# kontributors
z
Another thing to add: it seems like variations of
measureTimeMillisWithResult
already exist in the codebase (
core/util.runtime/src/org/jetbrains/kotlin/utils/addToStdlib.kt
and
plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/util/misc.kt
) which could be replaced by the fixed version proposed.
d
So, I see here several issues: - add
callsInPlace
contract to
measureTimeMillis
. This most probably will be accepted, as it is quite sane proposition, but I don't think Kotlin compatibility policy allows releasing such changes in incremental (1.3.X) updates. - change behavior of
measureTimeMillis
-- this is more deep design question, and it has to be discussed (and all alternatives should be considered) before implementing anything - yes, when (and if) stdlib will have such API, it totally make sense to migrate compiler codebase to those changes. Regardless, I highly suggest to create YouTrack issues for each of those, because they need different kinds of discussion (and may actually have different resolutions)
z
Thanks for your feedback. Regarding addition of contracts, I will create a YouTrack issue (I would extend it to both functions). Edit: Somebody already did (https://youtrack.jetbrains.com/issue/KT-27856). I currently don't understand how it might influence compatibility (as it just adds additional information for the compiler to make better decisions) ... could you please elaborate on this? For changing the behavior of
measureTimeMillis
I don't think I need to take action, as there's already a ticket.
d
Formally, Kotlin guarantees two-way (i.e. backward and forward) compatibility of some components (notably, stdlib) within one major version. In particular, it means that if code can be compiled against stdlib of version, say, 1.3.40, it should be also compilable against stdlib of versions 1.3.0, 1.3.10, 1.3.20, 1.3.21, etc... Now imagine that we actually add contract to
measureTimeMillis
in stdlib, say, 1.3.40. Then, code like from your initial example will be compilable against stdlib 1.3.40, but it will be a error against earlier 1.3.X versions, like 1.3.30 (because 1.3.30 hadn't had contract on
measureTimeMillis
) And we already have one 1.3.X version without contract on
measureTimeMillis
-- 1.3.0 (which is, admittedly, our fault). That being said, those rules are not something set in stone, so there can be exceptions, but it requires more formal process of approval
👍 1
z
Ok, got it ... thanks for the detailed clarification.