Getting this new warning after updating to Kotlin ...
# announcements
e
Getting this new warning after updating to Kotlin 1.5.20:
JvmField cannot be applied to a property of an inline class type. This warning will become an error in further releases
I didn't see this mentioned anywhere in the release notes (or the GitHub release). Is there something pointing to this?
a
I think the warning was added in https://youtrack.jetbrains.com/issue/KT-32753 but I'm not sure it's specifically related to inline classes. Can you share a code sample to reproduce?
e
@Alexey Belkov [JB] this might be unrelated to that (or a bug) because it's happening on a property in the primary constructor, but it's not overriding anything:
Copy code
private inner class FindQuery<out T : Any>(
    @JvmField
    public val forId: WaitlistSurveySubmissionId,
    mapper: (SqlCursor) -> T
  ) : Query<T>(find, mapper) {
    public override fun execute(): SqlCursor = driver.executeQuery(1040459002,
        """SELECT * FROM WaitlistSurveySubmission WHERE id = ?""", 1) {
      bindString(1, database.WaitlistSurveySubmissionAdapter.idAdapter.encode(forId))
    }

    public override fun toString(): String = "WaitlistSurveySubmission.sq:find"
  }
a
@eygraber I think the new warning is expected here. Judging by the commit https://github.com/JetBrains/kotlin/commit/30341e38238b035934ed3cd15c0695640442ccb8, we just didn't check such properties in the primary constructor before. Consider this example:
Copy code
inline class I(val x: Int)

class C(
    @JvmField // warning, will be error in 1.6
    val i: I
) {
    @JvmField // already error in 1.5
    val ii: I = I(42)
}
e
Ah so inline classes were already not allowed to be a
@JvmField
, but until now this wasn't detected in a primary constructor?
a
Yes
👍 1