Repository: JetBrains/kotlin
File: core/reflection.jvm/src/kotlin/reflect/jvm/internal/calls/InlineClassAwareCaller.kt (Kotlin)

Code before:

            else -> 0
        }

        val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes ->
            val extensionReceiverType = descriptor.extensionReceiverParameter?.type
            if (extensionReceiverType != null) {
                kotlinParameterTypes.add(extensionReceiverType)
            } else if (descriptor is ConstructorDescriptor) {
                val constructedClass = descriptor.constructedClass
                if (constructedClass.isInner) {
                    kotlinParameterTypes.add((constructedClass.containingDeclaration as ClassDescriptor).defaultType)
                }
            } else {
                val containingDeclaration = descriptor.containingDeclaration
                if (containingDeclaration is ClassDescriptor && containingDeclaration.isInlineClass()) {
                    kotlinParameterTypes.add(containingDeclaration.defaultType)
                }
            }

            descriptor.valueParameters.mapTo(kotlinParameterTypes, ValueParameterDescriptor::getType)
        }

        // If the default argument is set,
        // (kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE masks and one marker are added to the end of the argument.
        val extraArgumentsTail = (if (isDefault) ((kotlinParameterTypes.size + 31) / Integer.SIZE) + 1 else 0) +
                (if (descriptor is FunctionDescriptor && descriptor.isSuspend) 1 else 0)
        val expectedArgsSize = kotlinParameterTypes.size + shift + extraArgumentsTail
        if (arity != expectedArgsSize) {
            throw KotlinReflectionInternalError(
                "Inconsistent number of parameters in the descriptor and Java reflection object: $arity != $expectedArgsSize\n" +
                        "Calling: $descriptor\n" +
                        "Parameter types: ${this.parameterTypes})\n" +
                        "Default: $isDefault"
            )
        }

        // maxOf is needed because in case of a bound top level extension, shift can be -1 (see above). But in that case, we need not unbox
        // the extension receiver argument, since it has already been unboxed at compile time and generated into the reference
        val argumentRange = maxOf(shift, 0) until (kotlinParameterTypes.size + shift)

        val unbox = Array(expectedArgsSize) { i ->
            if (i in argumentRange) {
                kotlinParameterTypes[i - shift].toInlineClass()?.getUnboxMethod(descriptor)
            } else null
        }

        BoxUnboxData(argumentRange, unbox, box)
    }

    override fun call(args: Array<*>): Any? {

Review comment (suggestion):
```suggestion
        val extraArgumentsTail = (if (isDefault) ((kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE) + 1 else 0) +
```
Minor, but let's either use numbers in both places, or the constant `Integer.SIZE` in both places. :)

Code after:

            else -> 0
        }

        val kotlinParameterTypes: List<KotlinType> = ArrayList<KotlinType>().also { kotlinParameterTypes ->
            val extensionReceiverType = descriptor.extensionReceiverParameter?.type
            if (extensionReceiverType != null) {
                kotlinParameterTypes.add(extensionReceiverType)
            } else if (descriptor is ConstructorDescriptor) {
                val constructedClass = descriptor.constructedClass
                if (constructedClass.isInner) {
                    kotlinParameterTypes.add((constructedClass.containingDeclaration as ClassDescriptor).defaultType)
                }
            } else {
                val containingDeclaration = descriptor.containingDeclaration
                if (containingDeclaration is ClassDescriptor && containingDeclaration.isInlineClass()) {
                    kotlinParameterTypes.add(containingDeclaration.defaultType)
                }
            }

            descriptor.valueParameters.mapTo(kotlinParameterTypes, ValueParameterDescriptor::getType)
        }

        // If the default argument is set,
        // (kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE masks and one marker are added to the end of the argument.
        val extraArgumentsTail = (if (isDefault) ((kotlinParameterTypes.size + Integer.SIZE - 1) / Integer.SIZE) + 1 else 0) +
                (if (descriptor is FunctionDescriptor && descriptor.isSuspend) 1 else 0)
        val expectedArgsSize = kotlinParameterTypes.size + shift + extraArgumentsTail
        if (arity != expectedArgsSize) {
            throw KotlinReflectionInternalError(
                "Inconsistent number of parameters in the descriptor and Java reflection object: $arity != $expectedArgsSize\n" +
                        "Calling: $descriptor\n" +
                        "Parameter types: ${this.parameterTypes})\n" +
                        "Default: $isDefault"
            )
        }

        // maxOf is needed because in case of a bound top level extension, shift can be -1 (see above). But in that case, we need not unbox
        // the extension receiver argument, since it has already been unboxed at compile time and generated into the reference
        val argumentRange = maxOf(shift, 0) until (kotlinParameterTypes.size + shift)

        val unbox = Array(expectedArgsSize) { i ->
            if (i in argumentRange) {
                kotlinParameterTypes[i - shift].toInlineClass()?.getUnboxMethod(descriptor)
            } else null
        }

        BoxUnboxData(argumentRange, unbox, box)
    }

    override fun call(args: Array<*>): Any? {