Skip to content

toPatched requires Mutable variant even though it doesn't need it #13

@y9vad9

Description

@y9vad9

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).

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginvalidThis doesn't seem right

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions