Skip to content

Commit

Permalink
Store enumValue.name in enumValueName (not enumValue.toString()) (
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaMuravjov authored Dec 27, 2024
1 parent a43da92 commit 4c77f96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Descriptor2ValueConverter(private val workerClassLoader: ClassLoader) {

private fun `enum`(descriptor: UTestEnumValueDescriptor): Any {
val klass = descriptor.type.toJavaClass(workerClassLoader)
val enumValue = klass.enumConstants.find { it.toString() == descriptor.enumValueName }
val enumValue = klass.enumConstants.find { (it as Enum<*>).name == descriptor.enumValueName }
?: error("Can't build descriptor for enum")
for ((jcField, jcFieldDescr) in descriptor.fields) {
val jField = jcField.toJavaField(workerClassLoader) ?: continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ open class Value2DescriptorConverter(
)
}

private fun `enum`(value: Any, depth: Int): UTestEnumValueDescriptor {
private fun `enum`(value: Enum<*>, depth: Int): UTestEnumValueDescriptor {
val enumValueJcClass = jcClasspath.findClass(value::class.java.name)
val jcClass = if (!enumValueJcClass.isEnum) enumValueJcClass.superClass!! else enumValueJcClass
val fields = mutableMapOf<JcField, UTestValueDescriptor>()
val enumValueName = value.toString()
val enumValueName = value.name
val jcType = jcClass.toType()
val uTestEnumValueDescriptor =
UTestEnumValueDescriptor(jcType, enumValueName, fields, System.identityHashCode(value))
Expand Down

0 comments on commit 4c77f96

Please sign in to comment.