class GenericSubModel<S>(val value: S)
class ModelWithNestedGeneric<T>(val subModelElement: GenericSubModel<T>)
@Test
fun `generic type extraction`() {
val typeInfo = typeInfo<ModelWithNestedGeneric<String>>()
val property = ModelWithNestedGeneric::class.memberProperties.first()
val typeInfoForProperty = typeInfo<GenericSubModel<String>>()
assertEqualTypeInfo(typeInfoForProperty, property.returnTypeInfo(typeInfo.reifiedType))
}
e
e5l
07/06/2018, 1:56 PM
There is no way to do it in kotlin for now. You have to build proper java
Type
using java reflection
j
jlleitschuh
07/06/2018, 1:59 PM
@e5l I was hoping that I could avoid having to create my my own custom implementation of
ParameterizedType
.
I'm also not a huge fan of having a dependency upon apache commons.
I'd really love to have this project eventually get integrated into Ktor proper and I don't think that will happen with an external dependency upon apache commons 3.
Still looking for feedback on this proposal:
https://github.com/ktorio/ktor/issues/453