Repository: JetBrains/kotlin
File: compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/FunctionCodegen.kt (Kotlin)

Code before:
                if (this is IrConstructor) it else it or Opcodes.ACC_STATIC
            }
        }

        val isVararg = valueParameters.lastOrNull()?.varargElementType != null
        val isBridge = origin == IrDeclarationOrigin.BRIDGE || origin == IrDeclarationOrigin.BRIDGE_SPECIAL
        val modalityFlag = when ((this as? IrSimpleFunction)?.modality) {
            Modality.FINAL -> when {
                origin == JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER -> 0
                origin == IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER -> 0
                parentAsClass.isInterface && body != null -> 0
                parentAsClass.isAnnotationClass && !isStatic -> Opcodes.ACC_ABSTRACT
                else -> Opcodes.ACC_FINAL
            }
            Modality.ABSTRACT -> Opcodes.ACC_ABSTRACT
            // TODO transform interface modality on lowering to DefaultImpls
            else -> if (parentAsClass.isJvmInterface && body == null) Opcodes.ACC_ABSTRACT else 0
        }
        val isSynthetic = origin.isSynthetic || hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) ||
                (isSuspend && DescriptorVisibilities.isPrivate(visibility) && !isInline) || isReifiable()
        val isStrict = hasAnnotation(STRICTFP_ANNOTATION_FQ_NAME)
        val isSynchronized = hasAnnotation(SYNCHRONIZED_ANNOTATION_FQ_NAME)

        return getVisibilityAccessFlag() or modalityFlag or functionDeprecationFlags or
                (if (isStatic) Opcodes.ACC_STATIC else 0) or
                (if (isVararg && !isBridge) Opcodes.ACC_VARARGS else 0) or
                (if (isExternal) Opcodes.ACC_NATIVE else 0) or
                (if (isBridge) Opcodes.ACC_BRIDGE else 0) or
                (if (isSynthetic) Opcodes.ACC_SYNTHETIC else 0) or
                (if (isStrict) Opcodes.ACC_STRICT else 0) or
                (if (isSynchronized) Opcodes.ACC_SYNCHRONIZED else 0)
    }

    private fun getThrownExceptions(function: IrFunction): List<String>? {
        if (context.state.languageVersionSettings.supportsFeature(LanguageFeature.DoNotGenerateThrowsForDelegatedKotlinMembers) &&
            function.origin == IrDeclarationOrigin.DELEGATED_MEMBER
        ) return null

        // @Throws(vararg exceptionClasses: KClass<out Throwable>)
        val exceptionClasses = function.getAnnotation(JVM_THROWS_ANNOTATION_FQ_NAME)?.getValueArgument(0) ?: return null
        return (exceptionClasses as IrVararg).elements.map { exceptionClass ->
            context.typeMapper.mapType((exceptionClass as IrClassReference).classType).internalName
        }
    }

    private fun generateAnnotationDefaultValueIfNeeded(methodVisitor: MethodVisitor) {
        getAnnotationDefaultValueExpression()?.let { defaultValueExpression ->
            val annotationCodegen = object : AnnotationCodegen(classCodegen, context) {
                override fun visitAnnotation(descr: String?, visible: Boolean): AnnotationVisitor {
                    return methodVisitor.visitAnnotationDefault()
                }

Review comment (suggestion):
Another minor nitpick, but I'd prefer if `&& !isBridge` was a part of the `isVararg` value declaration, just to avoid misusing `isVararg` between its declaration and this usage

Code after:
                if (this is IrConstructor) it else it or Opcodes.ACC_STATIC
            }
        }

        val isVararg = valueParameters.lastOrNull()?.varargElementType != null && !isBridge()
        val modalityFlag = when ((this as? IrSimpleFunction)?.modality) {
            Modality.FINAL -> when {
                origin == JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER -> 0
                origin == IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER -> 0
                parentAsClass.isInterface && body != null -> 0
                parentAsClass.isAnnotationClass -> if (isStatic) 0 else Opcodes.ACC_ABSTRACT
                else -> Opcodes.ACC_FINAL
            }
            Modality.ABSTRACT -> Opcodes.ACC_ABSTRACT
            // TODO transform interface modality on lowering to DefaultImpls
            else -> if (parentAsClass.isJvmInterface && body == null) Opcodes.ACC_ABSTRACT else 0
        }
        val isSynthetic = origin.isSynthetic || hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) ||
                (isSuspend && DescriptorVisibilities.isPrivate(visibility) && !isInline) || isReifiable()
        val isStrict = hasAnnotation(STRICTFP_ANNOTATION_FQ_NAME)
        val isSynchronized = hasAnnotation(SYNCHRONIZED_ANNOTATION_FQ_NAME)

        return getVisibilityAccessFlag() or modalityFlag or functionDeprecationFlags or
                (if (isStatic) Opcodes.ACC_STATIC else 0) or
                (if (isVararg) Opcodes.ACC_VARARGS else 0) or
                (if (isExternal) Opcodes.ACC_NATIVE else 0) or
                (if (isBridge()) Opcodes.ACC_BRIDGE else 0) or
                (if (isSynthetic) Opcodes.ACC_SYNTHETIC else 0) or
                (if (isStrict) Opcodes.ACC_STRICT else 0) or
                (if (isSynchronized) Opcodes.ACC_SYNCHRONIZED else 0)
    }

    private fun getThrownExceptions(function: IrFunction): List<String>? {
        if (context.state.languageVersionSettings.supportsFeature(LanguageFeature.DoNotGenerateThrowsForDelegatedKotlinMembers) &&
            function.origin == IrDeclarationOrigin.DELEGATED_MEMBER
        ) return null

        // @Throws(vararg exceptionClasses: KClass<out Throwable>)
        val exceptionClasses = function.getAnnotation(JVM_THROWS_ANNOTATION_FQ_NAME)?.getValueArgument(0) ?: return null
        return (exceptionClasses as IrVararg).elements.map { exceptionClass ->
            context.typeMapper.mapType((exceptionClass as IrClassReference).classType).internalName
        }
    }

    private fun generateAnnotationDefaultValueIfNeeded(methodVisitor: MethodVisitor) {
        getAnnotationDefaultValueExpression()?.let { defaultValueExpression ->
            val annotationCodegen = object : AnnotationCodegen(classCodegen, context) {
                override fun visitAnnotation(descr: String?, visible: Boolean): AnnotationVisitor {
                    return methodVisitor.visitAnnotationDefault()
                }
            }