diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BoxedVsPrimitiveBranchedValues.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BoxedVsPrimitiveBranchedValues.kt index 849985c544a..05a9cd23974 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BoxedVsPrimitiveBranchedValues.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BoxedVsPrimitiveBranchedValues.kt @@ -13,20 +13,20 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter abstract class NumberLikeCompare( - left: StackValue, - right: StackValue, - operandType: Type, - private val opToken: IElementType + left: StackValue, + right: StackValue, + operandType: Type, + private val opToken: IElementType ) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) { override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int = - NumberCompare.patchOpcode(opcode, v, opToken, operandType) + NumberCompare.patchOpcode(opcode, v, opToken, operandType) } abstract class SafeCallFusedWithPrimitiveEqualityBase( - opToken: IElementType, - operandType: Type, - left: StackValue, - right: StackValue + opToken: IElementType, + operandType: Type, + left: StackValue, + right: StackValue ) : NumberLikeCompare(left, right, operandType, opToken) { private val trueIfEqual = opToken == KtTokens.EQEQ || opToken == KtTokens.EQEQEQ @@ -80,12 +80,12 @@ abstract class SafeCallFusedWithPrimitiveEqualityBase( class SafeCallToPrimitiveEquality( - opToken: IElementType, - operandType: Type, - left: StackValue, - right: StackValue, - private val safeReceiverType: Type, - private val safeReceiverIsNull: Label + opToken: IElementType, + operandType: Type, + left: StackValue, + right: StackValue, + private val safeReceiverType: Type, + private val safeReceiverIsNull: Label ) : SafeCallFusedWithPrimitiveEqualityBase(opToken, operandType, left, right) { override fun cleanupOnNullReceiver(v: InstructionAdapter) { v.mark(safeReceiverIsNull) @@ -95,12 +95,12 @@ class SafeCallToPrimitiveEquality( class PrimitiveToSafeCallEquality( - opToken: IElementType, - operandType: Type, - left: StackValue, - right: StackValue, - private val safeReceiverType: Type, - private val safeReceiverIsNull: Label + opToken: IElementType, + operandType: Type, + left: StackValue, + right: StackValue, + private val safeReceiverType: Type, + private val safeReceiverIsNull: Label ) : SafeCallFusedWithPrimitiveEqualityBase(opToken, operandType, left, right) { override fun cleanupOnNullReceiver(v: InstructionAdapter) { v.mark(safeReceiverIsNull) @@ -111,10 +111,10 @@ class PrimitiveToSafeCallEquality( class BoxedToPrimitiveEquality private constructor( - leftBoxed: StackValue, - rightPrimitive: StackValue, - primitiveType: Type, - private val frameMap: FrameMap + leftBoxed: StackValue, + rightPrimitive: StackValue, + primitiveType: Type, + private val frameMap: FrameMap ) : NumberLikeCompare(leftBoxed, rightPrimitive, primitiveType, KtTokens.EQEQ) { private val boxedType = arg1.type @@ -122,31 +122,30 @@ class BoxedToPrimitiveEquality private constructor( if (arg2!!.canHaveSideEffects()) { val tmp = frameMap.enterTemp(operandType) doJump( - v, jumpLabel, jumpIfFalse, - { - arg1.put(boxedType, v) - arg2.put(operandType, v) - v.store(tmp, operandType) - }, - { v.load(tmp, operandType) } + v, jumpLabel, jumpIfFalse, + { + arg1.put(boxedType, v) + arg2.put(operandType, v) + v.store(tmp, operandType) + }, + { v.load(tmp, operandType) } ) frameMap.leaveTemp(operandType) - } - else { + } else { doJump( - v, jumpLabel, jumpIfFalse, - { arg1.put(boxedType, v) }, - { arg2.put(operandType, v) } + v, jumpLabel, jumpIfFalse, + { arg1.put(boxedType, v) }, + { arg2.put(operandType, v) } ) } } private inline fun doJump( - v: InstructionAdapter, - jumpLabel: Label, - jumpIfFalse: Boolean, - putArg1: () -> Unit, - putArg2: () -> Unit + v: InstructionAdapter, + jumpLabel: Label, + jumpIfFalse: Boolean, + putArg1: () -> Unit, + putArg2: () -> Unit ) { val notNullLabel = Label() val endLabel = Label() @@ -169,34 +168,34 @@ class BoxedToPrimitiveEquality private constructor( companion object { @JvmStatic fun create( - opToken: IElementType, - left: StackValue, - leftType: Type, - right: StackValue, - rightType: Type, - frameMap: FrameMap + opToken: IElementType, + left: StackValue, + leftType: Type, + right: StackValue, + rightType: Type, + frameMap: FrameMap ): BranchedValue = - if (!isApplicable(opToken, leftType, rightType)) - throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") - else when (opToken) { - KtTokens.EQEQ -> BoxedToPrimitiveEquality(left, right, rightType, frameMap) - KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(left, right, rightType, frameMap)) - else -> throw AssertionError("Unexpected opToken: $opToken") - } + if (!isApplicable(opToken, leftType, rightType)) + throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") + else when (opToken) { + KtTokens.EQEQ -> BoxedToPrimitiveEquality(left, right, rightType, frameMap) + KtTokens.EXCLEQ -> Invert(BoxedToPrimitiveEquality(left, right, rightType, frameMap)) + else -> throw AssertionError("Unexpected opToken: $opToken") + } @JvmStatic fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) = - (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && - AsmUtil.isIntOrLongPrimitive(rightType) && - AsmUtil.isBoxedTypeOf(leftType, rightType) + (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && + AsmUtil.isIntOrLongPrimitive(rightType) && + AsmUtil.isBoxedTypeOf(leftType, rightType) } } abstract class PrimitiveToSomethingEquality protected constructor( - leftPrimitive: StackValue, - right: StackValue, - primitiveType: Type + leftPrimitive: StackValue, + right: StackValue, + primitiveType: Type ) : NumberLikeCompare(leftPrimitive, right, primitiveType, KtTokens.EQEQ) { protected val primitiveType = leftPrimitive.type protected val rightType = right.type @@ -227,9 +226,9 @@ protected constructor( class PrimitiveToBoxedEquality private constructor( - leftPrimitive: StackValue, - rightBoxed: StackValue, - primitiveType: Type + leftPrimitive: StackValue, + rightBoxed: StackValue, + primitiveType: Type ) : PrimitiveToSomethingEquality(leftPrimitive, rightBoxed, primitiveType) { private val boxedType = rightBoxed.type @@ -244,27 +243,27 @@ class PrimitiveToBoxedEquality private constructor( companion object { @JvmStatic fun create(opToken: IElementType, left: StackValue, leftType: Type, right: StackValue, rightType: Type): BranchedValue = - if (!isApplicable(opToken, leftType, rightType)) - throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") - else when (opToken) { - KtTokens.EQEQ -> PrimitiveToBoxedEquality(left, right, leftType) - KtTokens.EXCLEQ -> Invert(PrimitiveToBoxedEquality(left, right, leftType)) - else -> throw AssertionError("Unexpected opToken: $opToken") - } + if (!isApplicable(opToken, leftType, rightType)) + throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") + else when (opToken) { + KtTokens.EQEQ -> PrimitiveToBoxedEquality(left, right, leftType) + KtTokens.EXCLEQ -> Invert(PrimitiveToBoxedEquality(left, right, leftType)) + else -> throw AssertionError("Unexpected opToken: $opToken") + } @JvmStatic fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) = - (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && - AsmUtil.isIntOrLongPrimitive(leftType) && - AsmUtil.isBoxedTypeOf(rightType, leftType) + (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && + AsmUtil.isIntOrLongPrimitive(leftType) && + AsmUtil.isBoxedTypeOf(rightType, leftType) } } class PrimitiveToObjectEquality private constructor( - leftPrimitive: StackValue, - rightObject: StackValue, - primitiveType: Type + leftPrimitive: StackValue, + rightObject: StackValue, + primitiveType: Type ) : PrimitiveToSomethingEquality(leftPrimitive, rightObject, primitiveType) { private val boxedType = AsmUtil.boxType(primitiveType) @@ -281,18 +280,18 @@ class PrimitiveToObjectEquality private constructor( companion object { @JvmStatic fun create(opToken: IElementType, left: StackValue, leftType: Type, right: StackValue, rightType: Type): BranchedValue = - if (!isApplicable(opToken, leftType, rightType)) - throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") - else when (opToken) { - KtTokens.EQEQ -> PrimitiveToObjectEquality(left, right, leftType) - KtTokens.EXCLEQ -> Invert(PrimitiveToObjectEquality(left, right, leftType)) - else -> throw AssertionError("Unexpected opToken: $opToken") - } + if (!isApplicable(opToken, leftType, rightType)) + throw IllegalArgumentException("Not applicable for $opToken, $leftType, $rightType") + else when (opToken) { + KtTokens.EQEQ -> PrimitiveToObjectEquality(left, right, leftType) + KtTokens.EXCLEQ -> Invert(PrimitiveToObjectEquality(left, right, leftType)) + else -> throw AssertionError("Unexpected opToken: $opToken") + } @JvmStatic fun isApplicable(opToken: IElementType, leftType: Type, rightType: Type) = - (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && - AsmUtil.isIntOrLongPrimitive(leftType) && - rightType.sort == Type.OBJECT + (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ) && + AsmUtil.isIntOrLongPrimitive(leftType) && + rightType.sort == Type.OBJECT } } \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt index 3828da68046..e78531967ce 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt @@ -16,10 +16,10 @@ import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter open class BranchedValue( - val arg1: StackValue, - val arg2: StackValue? = null, - val operandType: Type, - val opcode: Int + val arg1: StackValue, + val arg2: StackValue? = null, + val operandType: Type, + val opcode: Int ) : StackValue(Type.BOOLEAN_TYPE) { override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) { @@ -59,8 +59,7 @@ open class BranchedValue( override fun loopJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { if (!jumpIfFalse) { v.fakeAlwaysTrueIfeq(jumpLabel) - } - else { + } else { v.fakeAlwaysFalseIfeq(jumpLabel) } } @@ -81,8 +80,7 @@ open class BranchedValue( override fun loopJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { if (jumpIfFalse) { v.fakeAlwaysTrueIfeq(jumpLabel) - } - else { + } else { v.fakeAlwaysFalseIfeq(jumpLabel) } } @@ -121,23 +119,23 @@ open class BranchedValue( } fun condJump(condition: StackValue): CondJump = - CondJump( - condition as? BranchedValue ?: BranchedValue(condition, null, Type.BOOLEAN_TYPE, IFEQ), - IFEQ - ) + CondJump( + condition as? BranchedValue ?: BranchedValue(condition, null, Type.BOOLEAN_TYPE, IFEQ), + IFEQ + ) fun cmp(opToken: IElementType, operandType: Type, left: StackValue, right: StackValue): StackValue = - if (operandType.sort == Type.OBJECT) - ObjectCompare(opToken, operandType, left, right) - else - NumberCompare(opToken, operandType, left, right) + if (operandType.sort == Type.OBJECT) + ObjectCompare(opToken, operandType, left, right) + else + NumberCompare(opToken, operandType, left, right) } } class And( - arg1: StackValue, - arg2: StackValue + arg1: StackValue, + arg2: StackValue ) : BranchedValue(BranchedValue.condJump(arg1), BranchedValue.condJump(arg2), Type.BOOLEAN_TYPE, IFEQ) { override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { @@ -149,8 +147,8 @@ class And( } class Or( - arg1: StackValue, - arg2: StackValue + arg1: StackValue, + arg2: StackValue ) : BranchedValue(BranchedValue.condJump(arg1), BranchedValue.condJump(arg2), Type.BOOLEAN_TYPE, IFEQ) { override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { @@ -184,14 +182,14 @@ class CondJump(val condition: BranchedValue, op: Int) : BranchedValue(condition, } class NumberCompare( - private val opToken: IElementType, - operandType: Type, - left: StackValue, - right: StackValue + private val opToken: IElementType, + operandType: Type, + left: StackValue, + right: StackValue ) : BranchedValue(left, right, operandType, NumberCompare.getNumberCompareOpcode(opToken)) { override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int = - patchOpcode(opcode, v, opToken, operandType) + patchOpcode(opcode, v, opToken, operandType) companion object { fun getNumberCompareOpcode(opToken: IElementType): Int = when (opToken) { @@ -230,10 +228,10 @@ class NumberCompare( } class ObjectCompare( - opToken: IElementType, - operandType: Type, - left: StackValue, - right: StackValue + opToken: IElementType, + operandType: Type, + left: StackValue, + right: StackValue ) : BranchedValue(left, right, operandType, ObjectCompare.getObjectCompareOpcode(opToken)) { companion object { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt index fb09dec11e5..d1a95c07f28 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/codegenUtil.kt @@ -57,9 +57,9 @@ import org.jetbrains.org.objectweb.asm.commons.Method import java.util.* fun generateIsCheck( - v: InstructionAdapter, - kotlinType: KotlinType, - asmType: Type + v: InstructionAdapter, + kotlinType: KotlinType, + asmType: Type ) { if (TypeUtils.isNullableType(kotlinType)) { val nope = Label() @@ -80,24 +80,22 @@ fun generateIsCheck( mark(end) } - } - else { + } else { TypeIntrinsics.instanceOf(v, kotlinType, asmType) } } fun generateAsCast( - v: InstructionAdapter, - kotlinType: KotlinType, - asmType: Type, - isSafe: Boolean + v: InstructionAdapter, + kotlinType: KotlinType, + asmType: Type, + isSafe: Boolean ) { if (!isSafe) { if (!TypeUtils.isNullableType(kotlinType)) { generateNullCheckForNonSafeAs(v, kotlinType) } - } - else { + } else { with(v) { dup() TypeIntrinsics.instanceOf(v, kotlinType, asmType) @@ -113,22 +111,30 @@ fun generateAsCast( } private fun generateNullCheckForNonSafeAs( - v: InstructionAdapter, - type: KotlinType + v: InstructionAdapter, + type: KotlinType ) { with(v) { dup() val nonnull = Label() ifnonnull(nonnull) - AsmUtil.genThrow(v, "kotlin/TypeCastException", "null cannot be cast to non-null type " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type)) + AsmUtil.genThrow( + v, + "kotlin/TypeCastException", + "null cannot be cast to non-null type " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(type) + ) mark(nonnull) } } -fun SpecialSignatureInfo.replaceValueParametersIn(sourceSignature: String?): String? - = valueParametersSignature?.let { sourceSignature?.replace("^\\(.*\\)".toRegex(), "($it)") } +fun SpecialSignatureInfo.replaceValueParametersIn(sourceSignature: String?): String? = + valueParametersSignature?.let { sourceSignature?.replace("^\\(.*\\)".toRegex(), "($it)") } -fun populateCompanionBackingFieldNamesToOuterContextIfNeeded(companion: KtObjectDeclaration, outerContext: FieldOwnerContext<*>, state: GenerationState) { +fun populateCompanionBackingFieldNamesToOuterContextIfNeeded( + companion: KtObjectDeclaration, + outerContext: FieldOwnerContext<*>, + state: GenerationState +) { val descriptor = state.bindingContext.get(BindingContext.CLASS, companion) if (descriptor == null || ErrorUtils.isError(descriptor)) { @@ -150,16 +156,20 @@ fun populateCompanionBackingFieldNamesToOuterContextIfNeeded(companion: KtObject } // TODO: inline and remove then ScriptCodegen is converted to Kotlin -fun mapSupertypesNames(typeMapper: KotlinTypeMapper, supertypes: List, signatureVisitor: JvmSignatureWriter?): Array = - supertypes.map { typeMapper.mapSupertype(it.defaultType, signatureVisitor).internalName }.toTypedArray() +fun mapSupertypesNames( + typeMapper: KotlinTypeMapper, + supertypes: List, + signatureVisitor: JvmSignatureWriter? +): Array = + supertypes.map { typeMapper.mapSupertype(it.defaultType, signatureVisitor).internalName }.toTypedArray() // Top level subclasses of a sealed class should be generated before that sealed class, // so that we'd generate the necessary accessor for its constructor afterwards fun sortTopLevelClassesAndPrepareContextForSealedClasses( - classOrObjects: List, - packagePartContext: PackageContext, - state: GenerationState + classOrObjects: List, + packagePartContext: PackageContext, + state: GenerationState ): List { fun prepareContextIfNeeded(descriptor: ClassDescriptor?) { if (DescriptorUtils.isSealedClass(descriptor)) { @@ -183,8 +193,7 @@ fun sortTopLevelClassesAndPrepareContextForSealedClasses( val descriptor = state.bindingContext.get(BindingContext.CLASS, classOrObject) if (descriptor == null) { result.add(classOrObject) - } - else { + } else { prepareContextIfNeeded(descriptor) descriptorToPsi[descriptor] = classOrObject } @@ -199,17 +208,17 @@ fun sortTopLevelClassesAndPrepareContextForSealedClasses( } fun CallableMemberDescriptor.isDefinitelyNotDefaultImplsMethod() = - this is JavaCallableMemberDescriptor || this.annotations.hasAnnotation(PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME) + this is JavaCallableMemberDescriptor || this.annotations.hasAnnotation(PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME) fun ClassBuilder.generateMethod( - debugString: String, - access: Int, - method: Method, - element: PsiElement?, - origin: JvmDeclarationOrigin, - state: GenerationState, - generate: InstructionAdapter.() -> Unit + debugString: String, + access: Int, + method: Method, + element: PsiElement?, + origin: JvmDeclarationOrigin, + state: GenerationState, + generate: InstructionAdapter.() -> Unit ) { val mv = this.newMethod(origin, access, method.name, method.descriptor, null, null) @@ -224,44 +233,44 @@ fun ClassBuilder.generateMethod( fun reportTarget6InheritanceErrorIfNeeded( - classDescriptor: ClassDescriptor, classElement: PsiElement, restrictedInheritance: List, state:GenerationState + classDescriptor: ClassDescriptor, classElement: PsiElement, restrictedInheritance: List, state: GenerationState ) { if (!restrictedInheritance.isEmpty()) { val groupBy = restrictedInheritance.groupBy { descriptor -> descriptor.containingDeclaration as ClassDescriptor } for ((key, value) in groupBy) { state.diagnostics.report( - ErrorsJvm.TARGET6_INTERFACE_INHERITANCE.on( - classElement, classDescriptor, key, - value.joinToString(separator = "\n", prefix = "\n") { - Renderers.COMPACT.render(JvmCodegenUtil.getDirectMember(it), RenderingContext.Empty) - } - ) + ErrorsJvm.TARGET6_INTERFACE_INHERITANCE.on( + classElement, classDescriptor, key, + value.joinToString(separator = "\n", prefix = "\n") { + Renderers.COMPACT.render(JvmCodegenUtil.getDirectMember(it), RenderingContext.Empty) + } + ) ) } } } fun CallableDescriptor.isJvmStaticInObjectOrClassOrInterface(): Boolean = - isJvmStaticIn { - DescriptorUtils.isNonCompanionObject(it) || - // This is necessary because for generation of @JvmStatic methods from companion of class A - // we create a synthesized descriptor containing in class A - DescriptorUtils.isClassOrEnumClass(it) || DescriptorUtils.isInterface(it) - } + isJvmStaticIn { + DescriptorUtils.isNonCompanionObject(it) || + // This is necessary because for generation of @JvmStatic methods from companion of class A + // we create a synthesized descriptor containing in class A + DescriptorUtils.isClassOrEnumClass(it) || DescriptorUtils.isInterface(it) + } fun CallableDescriptor.isJvmStaticInCompanionObject(): Boolean = - isJvmStaticIn { DescriptorUtils.isCompanionObject(it) } + isJvmStaticIn { DescriptorUtils.isCompanionObject(it) } private fun CallableDescriptor.isJvmStaticIn(predicate: (DeclarationDescriptor) -> Boolean): Boolean = - when (this) { - is PropertyAccessorDescriptor -> { - val propertyDescriptor = correspondingProperty - predicate(propertyDescriptor.containingDeclaration) && - (hasJvmStaticAnnotation() || propertyDescriptor.hasJvmStaticAnnotation()) - } - else -> predicate(containingDeclaration) && hasJvmStaticAnnotation() + when (this) { + is PropertyAccessorDescriptor -> { + val propertyDescriptor = correspondingProperty + predicate(propertyDescriptor.containingDeclaration) && + (hasJvmStaticAnnotation() || propertyDescriptor.hasJvmStaticAnnotation()) } + else -> predicate(containingDeclaration) && hasJvmStaticAnnotation() + } fun Collection.filterOutDescriptorsWithSpecialNames() = filterNot { it.name.isSpecial } @@ -271,10 +280,10 @@ class TypeAndNullability(@JvmField val type: Type, @JvmField val isNullable: Boo class JvmKotlinType(val type: Type, val kotlinType: KotlinType?) fun calcTypeForIEEE754ArithmeticIfNeeded( - expression: KtExpression?, - bindingContext: BindingContext, - descriptor: DeclarationDescriptor, - languageVersionSettings: LanguageVersionSettings + expression: KtExpression?, + bindingContext: BindingContext, + descriptor: DeclarationDescriptor, + languageVersionSettings: LanguageVersionSettings ): TypeAndNullability? { val ktType = expression.kotlinType(bindingContext) ?: return null @@ -300,7 +309,7 @@ fun calcTypeForIEEE754ArithmeticIfNeeded( fun KotlinType.asmType(typeMapper: KotlinTypeMapper) = typeMapper.mapType(this) fun KtExpression?.asmType(typeMapper: KotlinTypeMapper, bindingContext: BindingContext): Type = - this.kotlinType(bindingContext)?.asmType(typeMapper) ?: Type.VOID_TYPE + this.kotlinType(bindingContext)?.asmType(typeMapper) ?: Type.VOID_TYPE fun KtExpression?.kotlinType(bindingContext: BindingContext) = this?.let(bindingContext::getType) @@ -322,7 +331,7 @@ fun FunctionDescriptor.isGenericToArray(): Boolean { val elementType = typeParameters[0].defaultType return KotlinTypeChecker.DEFAULT.equalTypes(elementType, builtIns.getArrayElementType(returnType)) && - KotlinTypeChecker.DEFAULT.equalTypes(elementType, builtIns.getArrayElementType(paramType)) + KotlinTypeChecker.DEFAULT.equalTypes(elementType, builtIns.getArrayElementType(paramType)) } fun FunctionDescriptor.isNonGenericToArray(): Boolean { @@ -361,13 +370,13 @@ fun initializeVariablesForDestructuredLambdaParameters(codegen: ExpressionCodege } val destructuringDeclaration = - (DescriptorToSourceUtils.descriptorToDeclaration(parameterDescriptor) as? KtParameter)?.destructuringDeclaration - ?: error("Destructuring declaration for descriptor $parameterDescriptor not found") + (DescriptorToSourceUtils.descriptorToDeclaration(parameterDescriptor) as? KtParameter)?.destructuringDeclaration + ?: error("Destructuring declaration for descriptor $parameterDescriptor not found") codegen.initializeDestructuringDeclarationVariables( - destructuringDeclaration, - TransientReceiver(parameterDescriptor.type), - codegen.findLocalOrCapturedValue(parameterDescriptor) ?: error("Local var not found for parameter $parameterDescriptor") + destructuringDeclaration, + TransientReceiver(parameterDescriptor.type), + codegen.findLocalOrCapturedValue(parameterDescriptor) ?: error("Local var not found for parameter $parameterDescriptor") ) } @@ -383,9 +392,9 @@ inline fun FrameMap.useTmpVar(type: Type, block: (index: Int) -> Unit) { } fun InstructionAdapter.generateNewInstanceDupAndPlaceBeforeStackTop( - frameMap: FrameMap, - topStackType: Type, - newInstanceInternalName: String + frameMap: FrameMap, + topStackType: Type, + newInstanceInternalName: String ) { frameMap.useTmpVar(topStackType) { index -> store(index, topStackType) @@ -410,17 +419,17 @@ fun extractReificationArgument(type: KotlinType): Pair): StackValue = - generateReceiverValue(call.extensionReceiver ?: call.dispatchReceiver!!, false) + generateReceiverValue(call.extensionReceiver ?: call.dispatchReceiver!!, false) fun ExpressionCodegen.generateCallSingleArgument(call: ResolvedCall): StackValue = - gen(call.getFirstArgumentExpression()!!) + gen(call.getFirstArgumentExpression()!!) fun ClassDescriptor.isPossiblyUninitializedSingleton() = - DescriptorUtils.isEnumEntry(this) || - DescriptorUtils.isCompanionObject(this) && JvmCodegenUtil.isJvmInterface(this.containingDeclaration) + DescriptorUtils.isEnumEntry(this) || + DescriptorUtils.isCompanionObject(this) && JvmCodegenUtil.isJvmInterface(this.containingDeclaration) val CodegenContext<*>.parentContextsWithSelf get() = generateSequence(this) { it.parentContext }