Kotlin and reflection

I'm pretty sure i'm doing something wrong here but I can't get this reflection code to compile:

c.properties.forEach { p ->
  val fieldValue = p.get(source)

  c.mutableMemberProperty(p.name).set(target, fieldValue)

}

When I try to compile, i get this output:

:compileKotlin

e: src/main/kotlin/com/antwerkz/bottlerocket/configuration/ConfigBlock.kt: (67, 38): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:

public fun <K, V> kotlin.MutableMap<com.antwerkz.bottlerocket.configuration.ConfigBlock, kotlin.Any>.set(key: com.antwerkz.bottlerocket.configuration.ConfigBlock, value: kotlin.Any): kotlin.Any? defined in kotlin

:compileKotlin FAILED

This works but is less than ideal:

c.mutableMemberProperty(p.name).javaSetter?.invoke(target, fieldValue)

What am I missing?

What's the signature of "mutableMemberProperty" function? Probably either "target" or "fieldValue" does not fit the target parameter type.