diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 8802891780e..e3775684f08 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -248,7 +248,7 @@ class Fir2IrVisitor( val irFunction = declarationStorage.createIrFunction( anonymousFunction, irParent = conversionScope.parent(), - predefinedOrigin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA, + predefinedOrigin = IrDeclarationOrigin.LOCAL_FUNCTION, isLocal = true ) conversionScope.withFunction(irFunction) { @@ -257,7 +257,11 @@ class Fir2IrVisitor( val type = anonymousFunction.typeRef.toIrType() - IrFunctionExpressionImpl(startOffset, endOffset, type, irFunction, IrStatementOrigin.LAMBDA) + IrFunctionExpressionImpl( + startOffset, endOffset, type, irFunction, + if (irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) IrStatementOrigin.LAMBDA + else IrStatementOrigin.ANONYMOUS_FUNCTION + ) } } diff --git a/compiler/testData/ir/irText/declarations/parameters/lambdas.fir.ir.txt b/compiler/testData/ir/irText/declarations/parameters/lambdas.fir.ir.txt index d87697f7ae9..1d88276e171 100644 --- a/compiler/testData/ir/irText/declarations/parameters/lambdas.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/lambdas.fir.ir.txt @@ -47,8 +47,8 @@ FILE fqName: fileName:/lambdas.kt PROPERTY name:test4 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Function2 visibility:private [final,static] EXPRESSION_BODY - FUN_EXPR type=kotlin.Function2 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int, j:kotlin.Int) returnType:kotlin.Unit + FUN_EXPR type=kotlin.Function2 origin=ANONYMOUS_FUNCTION + FUN LOCAL_FUNCTION name: visibility:local modality:FINAL <> (i:kotlin.Int, j:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER name:i index:0 type:kotlin.Int VALUE_PARAMETER name:j index:1 type:kotlin.Int BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.ir.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.ir.txt index d98d2ca1681..1831a187fb7 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.fir.ir.txt @@ -26,8 +26,8 @@ FILE fqName: fileName:/variableAsFunctionCallWithGenerics.kt $receiver: VALUE_PARAMETER name: type:T of . BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0.> declared in ' - FUN_EXPR type=kotlin.Function0.> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:T of . + FUN_EXPR type=kotlin.Function0.> origin=ANONYMOUS_FUNCTION + FUN LOCAL_FUNCTION name: visibility:local modality:FINAL <> () returnType:T of . BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): T of . declared in .' GET_VAR ': T of . declared in .' type=T of . origin=null diff --git a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.ir.txt b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.ir.txt deleted file mode 100644 index ef23b4cf2d9..00000000000 --- a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.ir.txt +++ /dev/null @@ -1,110 +0,0 @@ -FILE fqName: fileName:/functionLiteralGenericSignature.kt - PROPERTY name:unitFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:unitFun type:kotlin.Function0 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .unitFun' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function0 - correspondingProperty: PROPERTY name:unitFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unitFun type:kotlin.Function0 visibility:private [final,static]' type=kotlin.Function0 origin=null - PROPERTY name:intFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:intFun type:kotlin.Function0 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .intFun' - CONST Int type=kotlin.Int value=42 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function0 - correspondingProperty: PROPERTY name:intFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intFun type:kotlin.Function0 visibility:private [final,static]' type=kotlin.Function0 origin=null - PROPERTY name:stringParamFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:stringParamFun type:kotlin.Function1 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (x: kotlin.String): kotlin.Unit declared in .stringParamFun' - GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 - correspondingProperty: PROPERTY name:stringParamFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function1 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:stringParamFun type:kotlin.Function1 visibility:private [final,static]' type=kotlin.Function1 origin=null - PROPERTY name:listFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:listFun type:kotlin.Function1, kotlin.collections.List> visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function1, kotlin.collections.List> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (l:kotlin.collections.List) returnType:kotlin.collections.List - VALUE_PARAMETER name:l index:0 type:kotlin.collections.List - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (l: kotlin.collections.List): kotlin.collections.List declared in .listFun' - GET_VAR 'l: kotlin.collections.List declared in .listFun.' type=kotlin.collections.List origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.collections.List> - correspondingProperty: PROPERTY name:listFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function1, kotlin.collections.List> declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:listFun type:kotlin.Function1, kotlin.collections.List> visibility:private [final,static]' type=kotlin.Function1, kotlin.collections.List> origin=null - PROPERTY name:mutableListFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:mutableListFun type:kotlin.Function1, kotlin.collections.MutableList> visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function1, kotlin.collections.MutableList> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (l:kotlin.collections.MutableList) returnType:kotlin.collections.MutableList - VALUE_PARAMETER name:l index:0 type:kotlin.collections.MutableList - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (l: kotlin.collections.MutableList): kotlin.collections.MutableList declared in .mutableListFun' - CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.Nothing origin=EXCLEXCL - : kotlin.Nothing - arg0: CONST Null type=kotlin.Nothing? value=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.collections.MutableList> - correspondingProperty: PROPERTY name:mutableListFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function1, kotlin.collections.MutableList> declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:mutableListFun type:kotlin.Function1, kotlin.collections.MutableList> visibility:private [final,static]' type=kotlin.Function1, kotlin.collections.MutableList> origin=null - PROPERTY name:funWithIn visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:funWithIn type:kotlin.Function1, kotlin.Unit> visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function1, kotlin.Unit> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.Comparable) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:kotlin.Comparable - BLOCK_BODY - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.Unit> - correspondingProperty: PROPERTY name:funWithIn visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function1, kotlin.Unit> declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:funWithIn type:kotlin.Function1, kotlin.Unit> visibility:private [final,static]' type=kotlin.Function1, kotlin.Unit> origin=null - PROPERTY name:extensionFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:extensionFun type:@[ExtensionFunctionType] kotlin.Function1 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Any) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER name: type:kotlin.Any - BLOCK_BODY - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:@[ExtensionFunctionType] kotlin.Function1 - correspondingProperty: PROPERTY name:extensionFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): @[ExtensionFunctionType] kotlin.Function1 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:extensionFun type:@[ExtensionFunctionType] kotlin.Function1 visibility:private [final,static]' type=@[ExtensionFunctionType] kotlin.Function1 origin=null - PROPERTY name:extensionWithArgFun visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:extensionWithArgFun type:@[ExtensionFunctionType] kotlin.Function2 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Long, x:kotlin.Any) returnType:java.util.Date - $receiver: VALUE_PARAMETER name: type:kotlin.Long - VALUE_PARAMETER name:x index:0 type:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (x: kotlin.Any): java.util.Date declared in .extensionWithArgFun' - CONSTRUCTOR_CALL 'public constructor () declared in java.util.Date' type=java.util.Date origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:@[ExtensionFunctionType] kotlin.Function2 - correspondingProperty: PROPERTY name:extensionWithArgFun visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): @[ExtensionFunctionType] kotlin.Function2 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:extensionWithArgFun type:@[ExtensionFunctionType] kotlin.Function2 visibility:private [final,static]' type=@[ExtensionFunctionType] kotlin.Function2 origin=null diff --git a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.kt.txt b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.kt.txt deleted file mode 100644 index aa648f6b93f..00000000000 --- a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.fir.kt.txt +++ /dev/null @@ -1,53 +0,0 @@ -val unitFun: Function0 - field = local fun () { - return Unit - } - - get - -val intFun: Function0 - field = local fun (): Int { - return 42 - } - - get - -val stringParamFun: Function1 - field = local fun (x: String) { - return Unit - } - - get - -val listFun: Function1, List> - field = local fun (l: List): List { - return l - } - - get - -val mutableListFun: Function1, MutableList> - field = local fun (l: MutableList): MutableList { - return CHECK_NOT_NULL(arg0 = null) - } - - get - -val funWithIn: Function1, Unit> - field = local fun (x: Comparable) { - } - - get - -val extensionFun: @ExtensionFunctionType Function1 - field = local fun Any.() { - } - - get - -val extensionWithArgFun: @ExtensionFunctionType Function2 - field = local fun Long.(x: Any): Date { - return Date() - } - - get diff --git a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.kt b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.kt index 5ef3919dde1..ce547226c41 100644 --- a/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.kt +++ b/compiler/testData/ir/irText/firProblems/functionLiteralGenericSignature.kt @@ -1,3 +1,5 @@ +// SKIP_KLIB_TEST +// FIR_IDENTICAL import java.util.Date val unitFun = { } diff --git a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.ir.txt b/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.ir.txt deleted file mode 100644 index 8b560429d5c..00000000000 --- a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.ir.txt +++ /dev/null @@ -1,13 +0,0 @@ -FILE fqName: fileName:/anonymousFunction.kt - PROPERTY name:anonymous visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:anonymous type:kotlin.Function0 visibility:private [final,static] - EXPRESSION_BODY - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit - BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function0 - correspondingProperty: PROPERTY name:anonymous visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0 declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anonymous type:kotlin.Function0 visibility:private [final,static]' type=kotlin.Function0 origin=null diff --git a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.kt.txt b/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.kt.txt deleted file mode 100644 index ef19f0f61aa..00000000000 --- a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.kt.txt +++ /dev/null @@ -1,6 +0,0 @@ -val anonymous: Function0 - field = local fun () { - println() - } - - get diff --git a/compiler/testData/ir/irText/lambdas/anonymousFunction.kt b/compiler/testData/ir/irText/lambdas/anonymousFunction.kt index 351cee15441..7794b2d1997 100644 --- a/compiler/testData/ir/irText/lambdas/anonymousFunction.kt +++ b/compiler/testData/ir/irText/lambdas/anonymousFunction.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_STDLIB val anonymous = fun() { println() } \ No newline at end of file