0

I retrieved a property of my class using:

 val prop = businessObject::class.memberProperties.first()

I can do this:

prop.javaGetter

But this method does not compile:

prop.javaSetter

Even though the method exists and is not deprecated

Alexey Soshin
  • 16,718
  • 2
  • 31
  • 40

1 Answers1

4

It's not compiling because memberProperties is a Collection<KProperty1>, and KProperty1 doesn't have any javaSetter property. But you can test if the property is in fact a KMutableProperty1, and if it is, after a cast or a smart cast, use its javaSetter property.

As you can see, the documentation helps. Use it.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255