-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Hi! I ran into an issue where if a class references a class that is in the parent package, imports are not added.
package me.test.data.inner
import at.kopyk.CopyExtensions
import me.test.data.Outer
@CopyExtensions
data class Inner(
val outer: Outer
)
package me.test.data
import at.kopyk.CopyExtensions
@CopyExtensions
data class Outer(
val test: String
)
The generated code for inner will look like this:
package me.test.`data`.`inner`
import kotlin.DslMarker
import kotlin.Unit
import me.test.`data`.`Outer$Mutable`
import me.test.`data`.`inner`.Inner
import me.test.`data`.`inner`.`Inner$DslMarker`
import me.test.`data`.`inner`.`Inner$Mutable`
private val generatedByKopyKat: Unit = Unit
@DslMarker
public annotation class `Inner$DslMarker`
@`Inner$DslMarker`
public class `Inner$Mutable`(
public var outer: `Outer$Mutable`,
public val old: Inner,
)
public fun `Inner$Mutable`.freeze(): Inner = me.test.`data`.`inner`.Inner(outer = outer.freeze())
public fun Inner.toMutable(): `Inner$Mutable` = me.test.`data`.`inner`.`Inner$Mutable`(old = this,
outer = outer.toMutable())
public inline fun Inner.copy(block: `Inner$Mutable`.() -> Unit): Inner =
toMutable().apply(block).freeze()
And fail with the error:
e: file:///kopy-kt-missing-import/build/generated/ksp/main/kotlin/me/test/data/inner/me.test.%60data%60.%60inner%60.Inner$Mutable.kt:21:89 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun `Inner$Mutable`.freeze(): Inner defined in me.test.data.inner in file me.test.`data`.`inner`.Inner$Mutable.kt
e: file:///kopy-kt-missing-import/build/generated/ksp/main/kotlin/me/test/data/inner/me.test.%60data%60.%60inner%60.Inner$Mutable.kt:24:19 Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun Inner.toMutable(): `Inner$Mutable` defined in me.test.data.inner in file me.test.`data`.`inner`.Inner$Mutable.kt
In order to fix this the following imports need to be added to the inner generated file:
import me.test.data.freeze
import me.test.data.toMutable
I created a reproducer at https://github.com/dronda-t/kopy-kt-missing-import if you want to try for yourself.
Metadata
Metadata
Assignees
Labels
No labels