ste
06/18/2023, 12:20 PMkotlinx.datetime
in particular, however...
I put some extension methods (e.g. LocalDate.Companion.now()
) in a KMM module (:utils:datetime
) under the package kotlinx.datetime
, so that I can seamlessly use my extensions from the whole code base.
Well, I don't know whether this is a good practice or not; but during build time, Gradle can't see some methods of the original kotlinx.datetime
(on the other hand, no errors from the IDE).
For instance, it complains about
public expect operator fun LocalDate.minus(period: DatePeriod): LocalDate
...as it thinks it's
public expect fun LocalDate.minus(value: Int, unit: DateTimeUnit.DateBased): LocalDate
However, if I rename my kotlinx.datetime
to something else, or use the latter method, it works... What am I missing here?Adam S
06/18/2023, 12:36 PMste
06/18/2023, 12:42 PMstate.journal.date - DatePeriod(days = 1)
e: No value passed for parameter 'unit'
e: 'operator' modifier is required on 'minus' in 'kotlinx.datetime'
e: Type mismatch: inferred type is DatePeriod but Int was expected
Adam S
06/18/2023, 12:51 PMste
06/18/2023, 1:15 PMcompileDebugKotlin
(from Android module)/`compileKotlinJvm` (from KMM module)...
Already toggled config cache, invalidated cache etc.
Kotlin 1.8.21, Gradle 8.1.
All I have to do to trigger the error is adding a dependency to my utils module:
implementation(libs.kotlin.datetime)
implementation(projects.utils.datetime)
ephemient
06/18/2023, 2:35 PMste
06/18/2023, 2:36 PMephemient
06/18/2023, 2:37 PMephemient
06/18/2023, 2:37 PMste
06/18/2023, 2:44 PMLocalDate.kt
), so it ended up creating a class with same package+name. Thanks!