ZacSweers / MoshiX

Extensions for Moshi including IR plugins, moshi-sealed, and more.
Apache License 2.0
492 stars 37 forks source link

Compilation fails if class contains a private field #551

Closed ansman closed 5 months ago

ansman commented 5 months ago

Trying to compile this:

package com.example 

@JsonClass(generateAdapter = true)
data class Test(
    val foo: String,
) {
    private var _bar: String? = null
    val bar: String
        get() = _bar ?: (foo + "bar").also { _bar = it }
}

Will fail with:

e: file:///path/to/repo/com/example/Test.kt:3:1 property _bar is not visible

This is using version 0.25.1

ZacSweers commented 5 months ago

This is intended behavior, use transient or @Json(ignore = true)