User: joe Date: 28 Jul 24 17:19 Revision: 88a475af50d03711db5afb579b6b53d3d5876381 Summary: Prevent replacement of $ with . in more places, fixes #2282 TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=9512&personal=false Index: src/main/kotlin/platform/mixin/reference/DescReference.kt =================================================================== --- src/main/kotlin/platform/mixin/reference/DescReference.kt (revision 7d1cd3a2811670fb0d18b8a5a96d2099c3767453) +++ src/main/kotlin/platform/mixin/reference/DescReference.kt (revision 88a475af50d03711db5afb579b6b53d3d5876381) @@ -21,6 +21,7 @@ package com.demonwav.mcdev.platform.mixin.reference import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.DESC +import com.demonwav.mcdev.platform.mixin.util.canonicalName import com.demonwav.mcdev.platform.mixin.util.findClassNodeByQualifiedName import com.demonwav.mcdev.util.MemberReference import com.demonwav.mcdev.util.findModule @@ -114,11 +115,11 @@ val argTypes = Type.getArgumentTypes(desc) if (argTypes.isNotEmpty()) { val argsText = if (argTypes.size == 1) { - "${argTypes[0].className.replace('$', '.')}.class" + "${argTypes[0].canonicalName}.class" } else { "{${ argTypes.joinToString(", ") { type -> - "${type.className.replace('$', '.')}.class" + "${type.canonicalName}.class" } }}" } @@ -134,7 +135,7 @@ descAnnotation.setDeclaredAttributeValue( "ret", elementFactory.createAnnotationMemberValueFromText( - "${returnType.className.replace('$', '.')}.class", + "${returnType.canonicalName}.class", descAnnotation, ), ) Index: src/main/kotlin/platform/mixin/util/AsmUtil.kt =================================================================== --- src/main/kotlin/platform/mixin/util/AsmUtil.kt (revision 7d1cd3a2811670fb0d18b8a5a96d2099c3767453) +++ src/main/kotlin/platform/mixin/util/AsmUtil.kt (revision 88a475af50d03711db5afb579b6b53d3d5876381) @@ -146,16 +146,17 @@ if (this == ExpressionASMUtils.INTLIKE_TYPE) { return PsiTypes.intType() } - val javaClassName = className.replace("(\\$)(\\D)".toRegex()) { "." + it.groupValues[2] } - return elementFactory.createTypeFromText(javaClassName, context) + return elementFactory.createTypeFromText(canonicalName, context) } val Type.canonicalName get() = computeCanonicalName(this) +private val DOLLAR_TO_DOT_REGEX = "\\$(?!\\d)".toRegex() + private fun computeCanonicalName(type: Type): String { return when (type.sort) { Type.ARRAY -> computeCanonicalName(type.elementType) + "[]".repeat(type.dimensions) - Type.OBJECT -> type.className.replace('$', '.') + Type.OBJECT -> type.className.replace(DOLLAR_TO_DOT_REGEX, ".") else -> type.className } } @@ -817,7 +818,7 @@ } append(name) } else { - append(returnType.className.replace('$', '.')) + append(returnType.canonicalName) append(' ') append(this@findOrConstructSourceMethod.name.toJavaIdentifier()) } @@ -827,7 +828,7 @@ if (index != 0) { append(", ") } - var typeName = param.className.replace('$', '.') + var typeName = param.canonicalName if (index == params.size - 1 && hasAccess(Opcodes.ACC_VARARGS) && typeName.endsWith("[]")) { typeName = typeName.replaceRange(typeName.length - 2, typeName.length, "...") }