Fix incorrect character replacement in ClassName.jvmInternalName
#KT-28682 Fixed
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
## 0.0.5
|
||||
|
||||
- [`KT-25371`](https://youtrack.jetbrains.com/issue/KT-25371) Support unsigned integers in kotlinx-metadata-jvm
|
||||
- [`KT-28682`](https://youtrack.jetbrains.com/issue/KT-28682) Wrong character replacement in ClassName.jvmInternalName of kotlinx-metadata-jvm
|
||||
|
||||
## 0.0.4
|
||||
|
||||
|
||||
@@ -16,4 +16,4 @@ import kotlinx.metadata.isLocal
|
||||
val ClassName.jvmInternalName: String
|
||||
get() =
|
||||
if (this.isLocal) substring(1)
|
||||
else replace('/', '$')
|
||||
else replace('.', '$')
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import java.net.URLClassLoader
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
class MetadataSmokeTest {
|
||||
@@ -144,4 +145,31 @@ class MetadataSmokeTest {
|
||||
|
||||
assertEquals("Hello, world!", result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun jvmInternalName() {
|
||||
class ClassNameReader : KmClassVisitor() {
|
||||
lateinit var className: ClassName
|
||||
|
||||
override fun visit(flags: Flags, name: ClassName) {
|
||||
className = name
|
||||
}
|
||||
}
|
||||
|
||||
class L
|
||||
|
||||
val l = ClassNameReader().run {
|
||||
(KotlinClassMetadata.read(L::class.java.readMetadata()) as KotlinClassMetadata.Class).accept(this)
|
||||
className
|
||||
}
|
||||
assertEquals(".kotlinx/metadata/test/MetadataSmokeTest\$jvmInternalName\$L", l)
|
||||
assertEquals("kotlinx/metadata/test/MetadataSmokeTest\$jvmInternalName\$L", l.jvmInternalName)
|
||||
|
||||
val coroutineContextKey = ClassNameReader().run {
|
||||
(KotlinClassMetadata.read(CoroutineContext.Key::class.java.readMetadata()) as KotlinClassMetadata.Class).accept(this)
|
||||
className
|
||||
}
|
||||
assertEquals("kotlin/coroutines/CoroutineContext.Key", coroutineContextKey)
|
||||
assertEquals("kotlin/coroutines/CoroutineContext\$Key", coroutineContextKey.jvmInternalName)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user