From e58e05f9beee4ed413c75ae6e50a5509f1409c0a Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Fri, 18 May 2018 15:28:10 +0200 Subject: [PATCH] Minor. Reformat --- .../common/DataClassMethodGenerator.kt | 22 +++++++++------ .../jvm/intrinsics/ArrayConstructor.kt | 9 ++++-- .../backend/jvm/lower/descriptorUtils.kt | 28 ++++++++++--------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/DataClassMethodGenerator.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/DataClassMethodGenerator.kt index b9a6ecd52e0..497e853b78b 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/DataClassMethodGenerator.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/DataClassMethodGenerator.kt @@ -78,20 +78,26 @@ abstract class DataClassMethodGenerator(protected val declaration: KtClassOrObje } private fun generateDataClassToStringIfNeeded(properties: List) { - val function = getMemberToGenerate(classDescriptor, "toString", - KotlinBuiltIns::isString, List::isEmpty) ?: return + val function = getMemberToGenerate( + classDescriptor, "toString", + KotlinBuiltIns::isString, List::isEmpty + ) ?: return generateToStringMethod(function, properties) } private fun generateDataClassHashCodeIfNeeded(properties: List) { - val function = getMemberToGenerate(classDescriptor, "hashCode", - KotlinBuiltIns::isInt, List::isEmpty) ?: return + val function = getMemberToGenerate( + classDescriptor, "hashCode", + KotlinBuiltIns::isInt, List::isEmpty + ) ?: return generateHashCodeMethod(function, properties) } private fun generateDataClassEqualsIfNeeded(properties: List) { - val function = getMemberToGenerate(classDescriptor, "equals", - KotlinBuiltIns::isBoolean) { parameters -> + val function = getMemberToGenerate( + classDescriptor, "equals", + KotlinBuiltIns::isBoolean + ) { parameters -> parameters.size == 1 && KotlinBuiltIns.isNullableAny(parameters.first().type) } ?: return generateEqualsMethod(function, properties) @@ -99,8 +105,8 @@ abstract class DataClassMethodGenerator(protected val declaration: KtClassOrObje private val dataProperties: List get() = primaryConstructorParameters - .filter { it.hasValOrVar() } - .map { bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it)!! } + .filter { it.hasValOrVar() } + .map { bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, it)!! } private val primaryConstructorParameters: List get() = (declaration as? KtClass)?.primaryConstructorParameters.orEmpty() diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayConstructor.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayConstructor.kt index accb3faa8d0..95ef2436c2c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayConstructor.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/ArrayConstructor.kt @@ -19,17 +19,22 @@ package org.jetbrains.kotlin.backend.jvm.intrinsics import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.codegen.BlockInfo import org.jetbrains.kotlin.backend.jvm.codegen.ExpressionCodegen +import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter object ArrayConstructor : IntrinsicMethod() { - override fun toCallable(expression: IrMemberAccessExpression, signature: JvmMethodSignature, context: JvmBackendContext): IrIntrinsicFunction { + override fun toCallable( + expression: IrMemberAccessExpression, + signature: JvmMethodSignature, + context: JvmBackendContext + ): IrIntrinsicFunction { return object : IrIntrinsicFunction(expression, signature, context, expression.argTypes(context)) { override fun invoke(v: InstructionAdapter, codegen: ExpressionCodegen, data: BlockInfo): StackValue = - codegen.generateCall(expression, this, data) + codegen.generateCall(expression, this, data) } } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/descriptorUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/descriptorUtils.kt index a39513c68e2..d3c3040052e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/descriptorUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/descriptorUtils.kt @@ -24,35 +24,37 @@ import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.name.Name fun FunctionDescriptor.toStatic( - newOwner: ClassOrPackageFragmentDescriptor, - name: Name = this.name, - dispatchReceiverClass: ClassDescriptor? = this.containingDeclaration as? ClassDescriptor + newOwner: ClassOrPackageFragmentDescriptor, + name: Name = this.name, + dispatchReceiverClass: ClassDescriptor? = this.containingDeclaration as? ClassDescriptor ): FunctionDescriptor { val newFunction = SimpleFunctionDescriptorImpl.create( - newOwner, AnnotationsImpl(emptyList()), - name, - CallableMemberDescriptor.Kind.DECLARATION, this.source + newOwner, AnnotationsImpl(emptyList()), + name, + CallableMemberDescriptor.Kind.DECLARATION, this.source ) var offset = 0 val dispatchReceiver = dispatchReceiverParameter?.let { ValueParameterDescriptorImpl.createWithDestructuringDeclarations( - newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("this"), - dispatchReceiverClass!!.defaultType, false, false, false, null, dispatchReceiverClass.source, null) + newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("this"), + dispatchReceiverClass!!.defaultType, false, false, false, null, dispatchReceiverClass.source, null + ) } val extensionReceiver = extensionReceiverParameter?.let { ValueParameterDescriptorImpl.createWithDestructuringDeclarations( - newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("receiver"), - it.value.type, false, false, false, null, it.source, null) + newFunction, null, offset++, AnnotationsImpl(emptyList()), Name.identifier("receiver"), + it.value.type, false, false, false, null, it.source, null + ) } val valueParameters = listOfNotNull(dispatchReceiver, extensionReceiver) + - valueParameters.map { it.copy(newFunction, it.name, it.index + offset) } + valueParameters.map { it.copy(newFunction, it.name, it.index + offset) } newFunction.initialize( - null, null, emptyList()/*TODO: type parameters*/, - valueParameters, returnType, Modality.FINAL, Visibilities.PUBLIC + null, null, emptyList()/*TODO: type parameters*/, + valueParameters, returnType, Modality.FINAL, Visibilities.PUBLIC ) return newFunction }