`toPatched` requires Mutable variant even though it doesn't need it
y9vad9 opened this issue · 0 comments
y9vad9 commented
Describe the bug
toPatched
function requires Mutable variant of entity even though it doesn't need it.
It generates next code:
public fun UserEntity.toPatched(patch: UserEntity): UserEntity {
val isMutable = this is MutableUserEntity
val base = if(isMutable) this as MutableUserEntity else this.toMutable()
patch.id?.let{
base.id = it
}
patch.firstName?.let{
base.firstName = it
}
patch.lastName?.let{
base.lastName = it
}
return if(isMutable) this else base.toImmutable()
}
To Reproduce
Steps to reproduce the behavior:
- Create entity with annotation
DtoImpl
without usingMutableImpl
(useImmutableImpl
) - Run generation
- Try to build the project
- See error
Expected behavior
I think it shouldn't use mutable variant (almost useless) at all or use it only when mutable variant is available (if we don't need producing instances).