implier icon indicating copy to clipboard operation
implier copied to clipboard

`toPatched` requires Mutable variant even though it doesn't need it

Open y9vad9 opened this issue 1 year ago • 0 comments

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:

  1. Create entity with annotation DtoImpl without using MutableImpl (use ImmutableImpl)
  2. Run generation
  3. Try to build the project
  4. 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).

y9vad9 avatar Aug 28 '22 21:08 y9vad9