javaClass to ::class.java migration problem

I’m trying to migrate to new RC version of Kotlin and found strange situation when eliminating deprecation warnings about .javaClass using.
My code was:

``val memberProperties: Collection<KProperty1<T, *>> = entity.javaClass.kotlin.memberProperties`

When I’ve changed it to:

val memberProperties: Collection<KProperty1<T, *>> = entity::class.java.kotlin.memberProperties

compiler says:
Error:(110, 89) Kotlin: Type inference failed. Expected type mismatch: inferred type is Collection<KProperty1<out T, Any?>> but Collection<KProperty1<T, *>> was expected

If I change type of my val to Collection<KProperty1<out T, *>> - it compiles, but I can’t use elements of collection as:

property.get(entity)

But by ctrl+click to memberProperties in both variants they both have type of Collection<KProperty1<T, *>>.

How to migrate this place?

1 Like