diff --git a/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_after.kt b/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_after.kt index 3752dc7aff3..b00ad3a2966 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_after.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_after.kt @@ -16,22 +16,20 @@ fun check(expected: String, actual: KType) { fun box(): String { check("java.lang.Iterable", typeOf>()) check("java.util.Iterator", typeOf>()) - // TODO: java.util.Collection - check("java.util.Collection", typeOf>()) + check("java.util.Collection", typeOf>()) check("java.util.List", typeOf>()) check("java.util.Set", typeOf>()) check("java.util.ListIterator", typeOf>()) - // TODO: java.util.Map - check("java.util.Map", typeOf>()) + check("java.util.Map", typeOf>()) check("java.util.Map\$Entry>", typeOf>>()) check("java.lang.Iterable", typeOf>()) check("java.util.Iterator", typeOf>()) - check("java.util.Collection", typeOf>()) + check("java.util.Collection", typeOf>()) check("java.util.List", typeOf>()) check("java.util.Set", typeOf>()) check("java.util.ListIterator", typeOf>()) - check("java.util.Map", typeOf>()) + check("java.util.Map", typeOf>()) check("java.util.Map\$Entry>", typeOf>>()) return "OK" diff --git a/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_before.kt b/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_before.kt index 12c2dfe8de0..cf62caee6bf 100644 --- a/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_before.kt +++ b/compiler/testData/codegen/box/reflection/typeOf/noReflect/mutableCollections_before.kt @@ -16,22 +16,20 @@ fun check(expected: String, actual: KType) { fun box(): String { check("java.lang.Iterable", typeOf>()) check("java.util.Iterator", typeOf>()) - // TODO: java.util.Collection - check("java.util.Collection", typeOf>()) + check("java.util.Collection", typeOf>()) check("java.util.List", typeOf>()) check("java.util.Set", typeOf>()) check("java.util.ListIterator", typeOf>()) - // TODO: java.util.Map - check("java.util.Map", typeOf>()) + check("java.util.Map", typeOf>()) check("java.util.Map\$Entry>", typeOf>>()) check("java.lang.Iterable", typeOf>()) check("java.util.Iterator", typeOf>()) - check("java.util.Collection", typeOf>()) + check("java.util.Collection", typeOf>()) check("java.util.List", typeOf>()) check("java.util.Set", typeOf>()) check("java.util.ListIterator", typeOf>()) - check("java.util.Map", typeOf>()) + check("java.util.Map", typeOf>()) check("java.util.Map\$Entry>", typeOf>>()) return "OK" diff --git a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt index d3347b90c87..53e954f6a40 100644 --- a/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt +++ b/libraries/stdlib/jvm/runtime/kotlin/jvm/internal/TypeReference.kt @@ -35,13 +35,14 @@ public class TypeReference /* @SinceKotlin("1.6") constructor */( (classifier.hashCode() * 31 + arguments.hashCode()) * 31 + isMarkedNullable.hashCode() override fun toString(): String = - asString() + Reflection.REFLECTION_NOT_AVAILABLE + asString(false) + Reflection.REFLECTION_NOT_AVAILABLE - private fun asString(): String { + private fun asString(convertPrimitiveToWrapper: Boolean): String { val javaClass = (classifier as? KClass<*>)?.java val klass = when { javaClass == null -> classifier.toString() javaClass.isArray -> javaClass.arrayClassName + convertPrimitiveToWrapper && javaClass.isPrimitive -> (classifier as KClass<*>).javaObjectType.name else -> javaClass.name } val args = @@ -70,7 +71,7 @@ public class TypeReference /* @SinceKotlin("1.6") constructor */( private fun KTypeProjection.asString(): String { if (variance == null) return "*" - val typeString = (type as? TypeReference)?.asString() ?: type.toString() + val typeString = (type as? TypeReference)?.asString(true) ?: type.toString() return when (variance) { KVariance.INVARIANT -> typeString KVariance.IN -> "in $typeString"