diff --git a/compiler/testData/codegen/boxAgainstJava/reflection/properties/equalsHashCodeToString.kt b/compiler/testData/codegen/boxAgainstJava/reflection/properties/equalsHashCodeToString.kt index ba0904a8f99..803e585fe7e 100644 --- a/compiler/testData/codegen/boxAgainstJava/reflection/properties/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/boxAgainstJava/reflection/properties/equalsHashCodeToString.kt @@ -4,8 +4,8 @@ import kotlin.test.* import test.equalsHashCodeToString as J fun box(): String { - assertEquals("val test.equalsHashCodeToString.b", (J::b).toString()) - assertEquals("var test.equalsHashCodeToString.c", (J::c).toString()) + assertEquals("val test.equalsHashCodeToString.b: kotlin.Boolean", (J::b).toString()) + assertEquals("var test.equalsHashCodeToString.c: kotlin.Char", (J::c).toString()) assertTrue(J::b == J::b) assertFalse(J::c == J::b) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt index 5f4f70ce558..2f35b6ee766 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt @@ -8,6 +8,9 @@ fun check(expected: String, p: KProperty1<*, *>) { assert(s.startsWith("val ") || s.startsWith("var ")) { "Fail val/var: $s" } s = s.substring(4) + // Strip property type + s = s.substringBeforeLast(':') + // Strip property name, leave only receiver class s = s.substringBeforeLast('.') diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/memberExtensionToString.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/memberExtensionToString.kt index eaaea48ea70..76c950d3994 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/memberExtensionToString.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/memberExtensionToString.kt @@ -10,7 +10,7 @@ class A { fun box(): String { val p = javaClass().kotlin.memberExtensionProperties.single() - return if ("$p" == "var A.(kotlin.String.)id") "OK" else "Fail $p" + return if ("$p" == "var A.(kotlin.String.)id: kotlin.String") "OK" else "Fail $p" val q = javaClass().kotlin.declaredFunctions.single() if ("$q" != "fun A.(kotlin.Int.)foo(): kotlin.Double") return "Fail q $q" diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyToString.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyToString.kt index 81c68d11010..ab130cea03d 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyToString.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyToString.kt @@ -16,11 +16,11 @@ fun assertToString(s: String, x: Any) { } fun box(): String { - assertToString("val top", ::top) - assertToString("var top2", ::top2) - assertToString("val kotlin.String.ext", String::ext) - assertToString("var kotlin.IntRange?.ext2", IntRange::ext2) - assertToString("val test.A.mem", A::mem) - assertToString("var test.B.mem", B::mem) + assertToString("val top: kotlin.Int", ::top) + assertToString("var top2: kotlin.Int", ::top2) + assertToString("val kotlin.String.ext: kotlin.Int", String::ext) + assertToString("var kotlin.IntRange?.ext2: kotlin.Int", IntRange::ext2) + assertToString("val test.A.mem: kotlin.String", A::mem) + assertToString("var test.B.mem: kotlin.String", B::mem) return "OK" } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt index 7cd70919978..852960034a6 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt @@ -56,11 +56,14 @@ object ReflectionObjectRenderer { } } - // TODO: include visibility, return type + // TODO: include visibility fun renderProperty(descriptor: PropertyDescriptor): String { return StringBuilder { append(if (descriptor.isVar) "var " else "val ") appendReceiversAndName(descriptor) + + append(": ") + append(renderType(descriptor.type)) }.toString() }