pniederw
10/31/2017, 3:18 AMKType rather than a Type)Marc Knaup
10/31/2017, 11:54 AMERROR type I only get if I don’t create an anonymous subclass at the call site (i.e. in the inline fun getKType).
I noticed however that the resulting KType (and KTypeProjection) has various issues:
• You cannot get the KClass or Class which was used to create the KType so you have to store that info separately.
• The KType lacks nullability information.
• The KTypeProjection doesn’t have star projection anymore (turns into out UpperBound? at runtime).
• KType itself isn’t generic and thus you lose compile-time safety when passing around `KType`s instead of `KClass`es.
• I think `KType`’s implementation isn’t optimized that much for performance. isSubtypeOf for example looks scary.
• KTypeProjection lacks isSubtypeOf or something similar to check whether two projections are compatible/assignable.Marc Knaup
10/31/2017, 11:59 AMParametrizedTypes for the same reason.
It doesn’t support some Type classes and multiple upper/lower generic bounds since they’re all not relevant in my case.pniederw
10/31/2017, 6:04 PMtoString() of the resulting KType always contains “ERROR: …” for me. I was particularly interested in the nullability information, but as you said, it’s not there.
kotlin-reflect feels a bit shaky and doesn’t seem quite there yet. also got lots of errors when debugging it.Marc Knaup
10/31/2017, 6:09 PMKType is constructed from Java’s Type since Java doesn’t have any info about nullability.pniederw
10/31/2017, 6:24 PMKType from java’s Type, I constructed it using kotlin reflection. same thing.Marc Knaup
10/31/2017, 6:26 PMKClass.createType allows you to specify nullability 😮pniederw
10/31/2017, 6:26 PMpniederw
10/31/2017, 6:27 PMKClass.supertypes.single().arguments.single().type!!Marc Knaup
10/31/2017, 6:29 PMpniederw
10/31/2017, 6:32 PMClass. why can’t it work for KClass too?pniederw
10/31/2017, 6:35 PMKClass.supertypes seemed like the equivalent of Class.getGenericSuperclass()Marc Knaup
10/31/2017, 6:36 PMMarc Knaup
10/31/2017, 6:36 PMKType is mostly useless at the moment imo.pniederw
10/31/2017, 6:37 PM