From 6f1a15c4cb421d3f47ff3b2c74205770c3b143e9 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 21 Mar 2026 16:40:30 -0400 Subject: [PATCH] Fix mixin autocomplete spinning indefinitely in classes with many lambdas --- .../kotlin/platform/mixin/util/AsmUtil.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/platform/mixin/util/AsmUtil.kt b/src/main/kotlin/platform/mixin/util/AsmUtil.kt index 7793e59a1..ce3e88fc7 100644 --- a/src/main/kotlin/platform/mixin/util/AsmUtil.kt +++ b/src/main/kotlin/platform/mixin/util/AsmUtil.kt @@ -30,7 +30,6 @@ import com.demonwav.mcdev.util.findMethods import com.demonwav.mcdev.util.findModule import com.demonwav.mcdev.util.findQualifiedClass import com.demonwav.mcdev.util.fullQualifiedName -import com.demonwav.mcdev.util.hasSyntheticMethod import com.demonwav.mcdev.util.innerIndexAndName import com.demonwav.mcdev.util.isErasureEquivalentTo import com.demonwav.mcdev.util.localClasses @@ -729,17 +728,20 @@ private fun findContainingMethod(clazz: ClassNode, lambdaMethod: MethodNode): Pa else -> return@nextInsn } - // check if this lambda generated a synthetic method + // Count every LambdaMetafactory invokedynamic unconditionally so the index matches + // a PSI walk that counts all lambda expressions and method references without needing + // to call hasSyntheticMethod to filter them. + lambdaCount++ + val lambdaCountThisLine = + lineNumber?.let { lambdaCountPerLine.merge(it, 1, Int::plus) } ?: lambdaCount + + // Only record an entry when the lambda generated a synthetic method in this class. if (invokedMethod.owner != clazz.name) return@nextInsn val invokedMethodNode = clazz.findMethod(MemberReference(invokedMethod.name, invokedMethod.desc)) if (invokedMethodNode == null || !invokedMethodNode.hasAccess(Opcodes.ACC_SYNTHETIC)) { return@nextInsn } - lambdaCount++ - val lambdaCountThisLine = - lineNumber?.let { lambdaCountPerLine.merge(it, 1, Int::plus) } ?: lambdaCount - if (invokedMethod.name == lambdaMethod.name && invokedMethod.desc == lambdaMethod.desc) { val locationInfo = SourceCodeLocationInfo(lambdaCount - 1, lineNumber, lambdaCountThisLine - 1) @@ -782,10 +784,8 @@ private fun findAssociatedLambda(project: Project, scope: GlobalSearchScope, cla // walk inside the reference first, visits the qualifier first (it's first in the bytecode) super.visitMethodReferenceExpression(expression) - if (expression.hasSyntheticMethod(clazz.version)) { - if (matcher.accept(expression)) { - stopWalking() - } + if (matcher.accept(expression)) { + stopWalking() } } },