From 4fb434c0de65cc8394b2b843d2fa91390b6ee2b2 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Mon, 1 Oct 2018 11:23:23 +0200 Subject: [PATCH] Move out jvm-specific part from ir-common #KT-27005 Fixed --- .../jetbrains/kotlin/backend/jvm/JvmLower.kt | 6 ++ .../jvm/lower/JvmCoercionToUnitPatcher.kt | 32 +++++++ .../transformations/InsertImplicitCasts.kt | 30 ++++--- .../ir/irText/declarations/kt27005.kt | 5 ++ .../ir/irText/declarations/kt27005.txt | 15 ++++ .../expressions/catchParameterAccess.txt | 6 +- .../irText/expressions/extFunInvokeAsFun.txt | 16 ++-- .../expressions/implicitCastToNonNull.txt | 8 +- .../expressions/variableAsFunctionCall.txt | 14 ++- .../ir/irText/lambdas/nonLocalReturn.txt | 88 ++++++++----------- .../kotlin/ir/IrTextTestCaseGenerated.java | 5 ++ 11 files changed, 136 insertions(+), 89 deletions(-) create mode 100644 compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmCoercionToUnitPatcher.kt create mode 100644 compiler/testData/ir/irText/declarations/kt27005.kt create mode 100644 compiler/testData/ir/irText/declarations/kt27005.txt diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt index b39bd15b8cf..5466855ed81 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmLower.kt @@ -23,12 +23,18 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.util.PatchDeclarationParentsVisitor +import org.jetbrains.kotlin.ir.util.TypeTranslator import org.jetbrains.kotlin.ir.visitors.acceptVoid import org.jetbrains.kotlin.name.NameUtils class JvmLower(val context: JvmBackendContext) { fun lower(irFile: IrFile) { // TODO run lowering passes as callbacks in bottom-up visitor + JvmCoercionToUnitPatcher( + context.builtIns, + context.irBuiltIns, + TypeTranslator(context.ir.symbols.externalSymbolTable, context.state.languageVersionSettings) + ).lower(irFile) FileClassLowering(context).lower(irFile) KCallableNamePropertyLowering(context).lower(irFile) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmCoercionToUnitPatcher.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmCoercionToUnitPatcher.kt new file mode 100644 index 00000000000..fbb66bb1e3d --- /dev/null +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmCoercionToUnitPatcher.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.jvm.lower + +import org.jetbrains.kotlin.backend.common.FileLoweringPass +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.util.TypeTranslator +import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid +import org.jetbrains.kotlin.psi2ir.transformations.InsertImplicitCasts + +class JvmCoercionToUnitPatcher(builtIns: KotlinBuiltIns, irBuiltIns: IrBuiltIns, typeTranslator: TypeTranslator) : + InsertImplicitCasts(builtIns, irBuiltIns, typeTranslator), FileLoweringPass { + + override fun lower(irFile: IrFile) { + irFile.transformChildrenVoid(this) + } + + override fun IrExpression.coerceToUnit(): IrExpression { + if (isUnitSubtype(getKotlinType(this)) && this is IrCall) { + return coerceToUnitIfNeeded(this.symbol.descriptor.original.returnType!!) + } + + return this + } +} \ No newline at end of file diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt index bc25c2cb0ea..01cbda8fe72 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt @@ -23,11 +23,13 @@ import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrField import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classifierOrFail import org.jetbrains.kotlin.ir.types.impl.originalKotlinType +import org.jetbrains.kotlin.ir.util.TypeTranslator import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.psi2ir.containsNull import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext @@ -40,15 +42,15 @@ import org.jetbrains.kotlin.types.typeUtil.makeNullable import org.jetbrains.kotlin.types.upperIfFlexible fun insertImplicitCasts(element: IrElement, context: GeneratorContext) { - element.transformChildren(InsertImplicitCasts(context), null) + element.transformChildren(InsertImplicitCasts(context.builtIns, context.irBuiltIns, context.typeTranslator), null) } -class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid() { +open class InsertImplicitCasts( + private val builtIns: KotlinBuiltIns, + private val irBuiltIns: IrBuiltIns, + private val typeTranslator: TypeTranslator +) : IrElementTransformerVoid() { - private val builtIns = context.builtIns - private val irBuiltIns = context.irBuiltIns - - private val typeTranslator = context.typeTranslator private fun KotlinType.toIrType() = typeTranslator.translateType(this) override fun visitCallableReference(expression: IrCallableReference): IrExpression = @@ -232,10 +234,16 @@ class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid( ) } - private fun IrExpression.coerceToUnit(): IrExpression { + protected open fun IrExpression.coerceToUnit(): IrExpression { val valueType = getKotlinType(this) + return coerceToUnitIfNeeded(valueType) + } - return if (KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, builtIns.unitType)) + protected fun getKotlinType(irExpression: IrExpression) = + irExpression.type.originalKotlinType!! + + protected fun IrExpression.coerceToUnitIfNeeded(valueType: KotlinType): IrExpression { + return if (isUnitSubtype(valueType)) this else IrTypeOperatorCallImpl( @@ -247,10 +255,8 @@ class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid( ) } - private fun getKotlinType(irExpression: IrExpression) = - if (irExpression is IrCall) - irExpression.symbol.descriptor.original.returnType!! - else irExpression.type.originalKotlinType!! + protected fun isUnitSubtype(valueType: KotlinType) = + KotlinTypeChecker.DEFAULT.isSubtypeOf(valueType, builtIns.unitType) private fun KotlinType.isBuiltInIntegerType(): Boolean = KotlinBuiltIns.isByte(this) || diff --git a/compiler/testData/ir/irText/declarations/kt27005.kt b/compiler/testData/ir/irText/declarations/kt27005.kt new file mode 100644 index 00000000000..65070eb05bf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt27005.kt @@ -0,0 +1,5 @@ +suspend fun foo() = baz() +suspend fun bar() = baz() +suspend fun baz(): T { + TODO() +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/kt27005.txt b/compiler/testData/ir/irText/declarations/kt27005.txt new file mode 100644 index 00000000000..cbab1a14b34 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/kt27005.txt @@ -0,0 +1,15 @@ +FILE fqName: fileName:/kt27005.kt + FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit flags:suspend + BLOCK_BODY + RETURN type=kotlin.Nothing from='foo(): Unit' + CALL 'baz(): Unit' type=kotlin.Unit origin=null + : kotlin.Unit + FUN name:bar visibility:public modality:FINAL <> () returnType:kotlin.Any flags:suspend + BLOCK_BODY + RETURN type=kotlin.Nothing from='bar(): Any' + CALL 'baz(): Any' type=kotlin.Any origin=null + : kotlin.Any + FUN name:baz visibility:public modality:FINAL () returnType:T flags:suspend + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + BLOCK_BODY + CALL 'TODO(): Nothing' type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt index e948f2ed3dd..a92367d08ea 100644 --- a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt +++ b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt @@ -5,10 +5,8 @@ FILE fqName: fileName:/catchParameterAccess.kt RETURN type=kotlin.Nothing from='test(() -> Unit): Unit' TRY type=kotlin.Unit try: BLOCK type=kotlin.Unit origin=null - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter f: () -> Unit' type=() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + CALL 'invoke(): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter f: () -> Unit' type=() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION CATCH parameter=e: Exception /* = Exception */ VAR CATCH_PARAMETER name:e type:kotlin.Exception /* = java.lang.Exception */ flags:val BLOCK type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.txt b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.txt index 55f1d98acc7..e9b55928999 100644 --- a/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.txt +++ b/compiler/testData/ir/irText/expressions/extFunInvokeAsFun.txt @@ -4,19 +4,15 @@ FILE fqName: fileName:/extFunInvokeAsFun.kt VALUE_PARAMETER name:block index:1 type:kotlin.Any?.() -> kotlin.Unit flags: BLOCK_BODY RETURN type=kotlin.Nothing from='with1(Any?, Any?.() -> Unit): Unit' - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(Any?): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter block: Any?.() -> Unit' type=kotlin.Any?.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION - p1: GET_VAR 'value-parameter receiver: Any?' type=kotlin.Any? origin=null + CALL 'invoke(Any?): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter block: Any?.() -> Unit' type=kotlin.Any?.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 'value-parameter receiver: Any?' type=kotlin.Any? origin=null FUN name:with2 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Any?.() -> kotlin.Unit) returnType:kotlin.Unit flags: VALUE_PARAMETER name:receiver index:0 type:kotlin.Any? flags: VALUE_PARAMETER name:block index:1 type:kotlin.Any?.() -> kotlin.Unit flags: BLOCK_BODY RETURN type=kotlin.Nothing from='with2(Any?, Any?.() -> Unit): Unit' - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(Any?): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter block: Any?.() -> Unit' type=kotlin.Any?.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION - p1: GET_VAR 'value-parameter receiver: Any?' type=kotlin.Any? origin=null + CALL 'invoke(Any?): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter block: Any?.() -> Unit' type=kotlin.Any?.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 'value-parameter receiver: Any?' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.txt index 53075b79f0b..46d27484233 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.txt @@ -74,9 +74,7 @@ FILE fqName: fileName:/implicitCastToNonNull.kt arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ arg0: GET_VAR 'value-parameter x: T' type=T origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(S): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter fn: (S) -> Unit' type=(S) -> kotlin.Unit origin=VARIABLE_AS_FUNCTION - p1: GET_VAR 'value-parameter x: T' type=T origin=null + then: CALL 'invoke(S): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter fn: (S) -> Unit' type=(S) -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + p1: GET_VAR 'value-parameter x: T' type=T origin=null diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt index 3f0fe8c31bf..36fe17fb4bb 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt @@ -13,19 +13,15 @@ FILE fqName: fileName:/variableAsFunctionCall.kt VALUE_PARAMETER name:f index:0 type:() -> kotlin.Unit flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test1(() -> Unit): Unit' - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter f: () -> Unit' type=() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + CALL 'invoke(): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter f: () -> Unit' type=() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION FUN name:test2 visibility:public modality:FINAL <> (f:kotlin.String.() -> kotlin.Unit) returnType:kotlin.Unit flags: VALUE_PARAMETER name:f index:0 type:kotlin.String.() -> kotlin.Unit flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test2(String.() -> Unit): Unit' - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'invoke(String): Unit' type=kotlin.Unit origin=INVOKE - $this: GET_VAR 'value-parameter f: String.() -> Unit' type=kotlin.String.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION - p1: CONST String type=kotlin.String value=hello + CALL 'invoke(String): Unit' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'value-parameter f: String.() -> Unit' type=kotlin.String.() -> kotlin.Unit origin=VARIABLE_AS_FUNCTION + p1: CONST String type=kotlin.String value=hello FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.String flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test3(): String' diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt index 48a57d4657c..cc9abf0541d 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt @@ -1,61 +1,51 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:test0 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags: BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null - : kotlin.Nothing - block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing flags: - BLOCK_BODY - RETURN type=kotlin.Nothing from='test0(): Unit' - GET_OBJECT 'Unit' type=kotlin.Unit - FUNCTION_REFERENCE '(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA + CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null + : kotlin.Nothing + block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test0(): Unit' + GET_OBJECT 'Unit' type=kotlin.Unit + FUNCTION_REFERENCE '(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags: BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null - : kotlin.Unit - block: BLOCK type=() -> kotlin.Unit origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: - BLOCK_BODY - RETURN type=kotlin.Nothing from='(): Unit' - GET_OBJECT 'Unit' type=kotlin.Unit - FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA + CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null + : kotlin.Unit + block: BLOCK type=() -> kotlin.Unit origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Unit' + GET_OBJECT 'Unit' type=kotlin.Unit + FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags: BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null - : kotlin.Unit - block: BLOCK type=() -> kotlin.Unit origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: - BLOCK_BODY - RETURN type=kotlin.Nothing from='(): Unit' - GET_OBJECT 'Unit' type=kotlin.Unit - FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA + CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null + : kotlin.Unit + block: BLOCK type=() -> kotlin.Unit origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Unit' + GET_OBJECT 'Unit' type=kotlin.Unit + FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit flags: BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null - : kotlin.Unit - block: BLOCK type=() -> kotlin.Unit origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: - BLOCK_BODY - RETURN type=kotlin.Nothing from='(): Unit' - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - typeOperand: CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public flags: superTypes:[kotlin.Any] - CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null - : kotlin.Nothing - block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing flags: - BLOCK_BODY - RETURN type=kotlin.Nothing from='(): Unit' - GET_OBJECT 'Unit' type=kotlin.Unit - FUNCTION_REFERENCE '(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA - FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA + CALL 'run(() -> Unit): Unit' type=kotlin.Unit origin=null + : kotlin.Unit + block: BLOCK type=() -> kotlin.Unit origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Unit' + CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null + : kotlin.Nothing + block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Unit' + GET_OBJECT 'Unit' type=kotlin.Unit + FUNCTION_REFERENCE '(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA + FUNCTION_REFERENCE '(): Unit' type=() -> kotlin.Unit origin=LAMBDA FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit flags: VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List flags: BLOCK_BODY diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 42fb4a38422..5f7feca1c15 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -259,6 +259,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/declarations/interfaceProperties.kt"); } + @TestMetadata("kt27005.kt") + public void testKt27005() throws Exception { + runTest("compiler/testData/ir/irText/declarations/kt27005.kt"); + } + @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt");