diff options
Diffstat (limited to 'formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.kt')
-rw-r--r-- | formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.kt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.kt b/formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.kt new file mode 100644 index 00000000..2b04274c --- /dev/null +++ b/formats/json-tests/jvmTest/src/kotlinx/serialization/test/TypeToken.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2017-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.serialization.test + +import java.lang.reflect.* + + +@PublishedApi +internal open class TypeBase<T> + +public inline fun <reified T> typeTokenOf(): Type { + val base = object : TypeBase<T>() {} + val superType = base::class.java.genericSuperclass!! + return (superType as ParameterizedType).actualTypeArguments.first()!! +} |