Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store enumValue.name in enumValueName (not enumValue.toString()) #102

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,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 @@ -205,11 +205,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
Loading