diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index 4db5e9cfc45..be7c8ae55e3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -76,8 +76,6 @@ import static org.jetbrains.org.objectweb.asm.Opcodes.*; public class AsmUtil { - public static final boolean IS_BUILT_WITH_ASM6 = Opcodes.API_VERSION <= Opcodes.ASM6; - private static final Set STRING_BUILDER_OBJECT_APPEND_ARG_TYPES = Sets.newHashSet( getType(String.class), getType(StringBuffer.class), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 1bd6dba4a4a..fa613bd2036 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -520,22 +520,9 @@ public class FunctionCodegen { Iterator iterator = valueParameters.iterator(); List kotlinParameterTypes = jvmSignature.getValueParameters(); - int syntheticParameterCount = 0; - for (int i = 0; i < kotlinParameterTypes.size(); i++) { - JvmMethodParameterSignature parameterSignature = kotlinParameterTypes.get(i); - JvmMethodParameterKind kind = parameterSignature.getKind(); - if (kind.isSkippedInGenericSignature()) { - if (AsmUtil.IS_BUILT_WITH_ASM6) { - markEnumOrInnerConstructorParameterAsSynthetic(mv, i, state.getClassBuilderMode()); - } - else { - syntheticParameterCount++; - } - } - } - if (!AsmUtil.IS_BUILT_WITH_ASM6) { - Asm7UtilKt.visitAnnotableParameterCount(mv, kotlinParameterTypes.size() - syntheticParameterCount); - } + int syntheticParameterCount = CollectionsKt.count(kotlinParameterTypes, signature -> signature.getKind().isSkippedInGenericSignature()); + + Asm7UtilKt.visitAnnotableParameterCount(mv, kotlinParameterTypes.size() - syntheticParameterCount); for (int i = 0; i < kotlinParameterTypes.size(); i++) { JvmMethodParameterSignature parameterSignature = kotlinParameterTypes.get(i); @@ -553,25 +540,12 @@ public class FunctionCodegen { if (annotated != null) { //noinspection ConstantConditions - AnnotationCodegen.forParameter(AsmUtil.IS_BUILT_WITH_ASM6 ? i : i - syntheticParameterCount, mv, innerClassConsumer, state) + AnnotationCodegen.forParameter(i - syntheticParameterCount, mv, innerClassConsumer, state) .genAnnotations(annotated, parameterSignature.getAsmType()); } } } - private static void markEnumOrInnerConstructorParameterAsSynthetic(MethodVisitor mv, int i, ClassBuilderMode mode) { - // IDEA's ClsPsi builder fails to annotate synthetic parameters - if (mode == ClassBuilderMode.LIGHT_CLASSES) return; - - // This is needed to avoid RuntimeInvisibleParameterAnnotations error in javac: - // see MethodWriter.visitParameterAnnotation() - - AnnotationVisitor av = mv.visitParameterAnnotation(i, "Ljava/lang/Synthetic;", true); - if (av != null) { - av.visitEnd(); - } - } - @Nullable private static Type getThisTypeForFunction( @NotNull FunctionDescriptor functionDescriptor, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt index 6854528fb2c..d52e1bb9688 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt @@ -221,22 +221,9 @@ private fun generateParameterAnnotations( ) { val iterator = irFunction.valueParameters.iterator() val kotlinParameterTypes = jvmSignature.valueParameters - var syntheticParameterCount = 0 - kotlinParameterTypes.forEachIndexed { i, parameterSignature -> - val kind = parameterSignature.kind - if (kind.isSkippedInGenericSignature) { - if (AsmUtil.IS_BUILT_WITH_ASM6) { - // This is needed to avoid RuntimeInvisibleParameterAnnotations error in javac: - // see MethodWriter.visitParameterAnnotation() - mv.visitParameterAnnotation(i, "Ljava/lang/Synthetic;", true)?.visitEnd() - } else { - syntheticParameterCount++ - } - } - } - if (!AsmUtil.IS_BUILT_WITH_ASM6) { - visitAnnotableParameterCount(mv, kotlinParameterTypes.size - syntheticParameterCount) - } + val syntheticParameterCount = kotlinParameterTypes.count { it.kind.isSkippedInGenericSignature } + + visitAnnotableParameterCount(mv, kotlinParameterTypes.size - syntheticParameterCount) kotlinParameterTypes.forEachIndexed { i, parameterSignature -> val kind = parameterSignature.kind @@ -248,7 +235,7 @@ private fun generateParameterAnnotations( if (!kind.isSkippedInGenericSignature) { AnnotationCodegen(innerClassConsumer, context) { descriptor, visible -> mv.visitParameterAnnotation( - if (AsmUtil.IS_BUILT_WITH_ASM6) i else i - syntheticParameterCount, + i - syntheticParameterCount, descriptor, visible ) diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt index bc750136ff0..840a3a2e69a 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt @@ -74,7 +74,7 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla name = "p${index - startParameterIndex}" } - val indexForAnnotation = if (AsmUtil.IS_BUILT_WITH_ASM6) index else index - startParameterIndex + val indexForAnnotation = index - startParameterIndex val visibleAnnotations = visibleParameterAnnotations?.get(indexForAnnotation) val invisibleAnnotations = invisibleParameterAnnotations?.get(indexForAnnotation) parameterInfos += ParameterInfo(0, name, type, visibleAnnotations, invisibleAnnotations)