poohbar
03/19/2018, 1:54 PMClass<PersonKotlin> klass1 = PersonKotlin.class;
KClass<PersonKotlin> kotlinClass1 = JvmClassMappingKt.getKotlinClass(klass1);
Class<PersonJava> klass2 = PersonJava.class;
KClass<PersonKotlin> kotlinClass2 = JvmClassMappingKt.getKotlinClass(klass2); // error
Although the types of klass1 and klass2 are identical the compiler recognizes that I can't call getKotlinClass on a Java class. How does it do that?dsavvinov
03/19/2018, 2:11 PMJvmClassMappingKt.getKotlinClass(klass2) returns KClass<PersonJava>, and you're assigning it to KClass<PersonKotlin> -- it's not "identical types", and they are not assignable to each other.poohbar
03/19/2018, 2:12 PMdsavvinov
03/19/2018, 2:12 PMpoohbar
03/19/2018, 2:13 PMpoohbar
03/19/2018, 2:16 PMkotlin-reflect. I thought those would be only available with the -parameters flag.dsavvinov
03/19/2018, 2:28 PMsince you are here, so what does it mean to get a KClass of a java class? is it identical to a KClass from a kotlin class?API-wise, it's the same. Of course, some of methods won't make sense for Java class -- then
KClass will just fallback on some reasonable defaults (e.g. for isSealed it will return false)