Skip to content

Commit

Permalink
[FIR]: Pass special origins for local functions (named and anonymous)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8ab546b)
  • Loading branch information
Mikhael Bogdanov authored and Space committed Aug 18, 2021
1 parent cd39bfe commit bd15d1c
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
Expand Up @@ -209,7 +209,7 @@ class Fir2IrVisitor(
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?): IrElement {
val irFunction = if (simpleFunction.visibility == Visibilities.Local) {
declarationStorage.createIrFunction(
simpleFunction, irParent = conversionScope.parent(), isLocal = true
simpleFunction, irParent = conversionScope.parent(), origin = IrDeclarationOrigin.LOCAL_FUNCTION, isLocal = true
)
} else {
declarationStorage.getCachedIrFunction(simpleFunction)!!
Expand All @@ -224,7 +224,7 @@ class Fir2IrVisitor(
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: Any?): IrElement {
return anonymousFunction.convertWithOffsets { startOffset, endOffset ->
val irFunction = declarationStorage.createIrFunction(
anonymousFunction, irParent = conversionScope.parent(), isLocal = true
anonymousFunction, irParent = conversionScope.parent(), origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA, isLocal = true
)
conversionScope.withFunction(irFunction) {
memberGenerator.convertFunctionContent(irFunction, anonymousFunction, containingClass = null)
Expand Down
Expand Up @@ -49,7 +49,7 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
CONST Int type=kotlin.Int value=10
VAR name:y type:kotlin.Int [val]
CONST Int type=kotlin.Int value=10
FUN name:localFunc visibility:local modality:FINAL <> () returnType:kotlin.Unit
FUN LOCAL_FUNCTION name:localFunc visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
BLOCK type=kotlin.Unit origin=FOR_LOOP
VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.IntIterator [val]
Expand Down
Expand Up @@ -48,7 +48,7 @@ FILE fqName:<root> fileName:/lambdas.kt
FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Function2<kotlin.Int, kotlin.Int, kotlin.Unit> visibility:private [final,static]
EXPRESSION_BODY
FUN_EXPR type=kotlin.Function2<kotlin.Int, kotlin.Int, kotlin.Unit> origin=LAMBDA
FUN name:<no name provided> visibility:local modality:FINAL <> (i:kotlin.Int, j:kotlin.Int) returnType:kotlin.Unit
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<no name provided> 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
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/ir/irText/expressions/kt47245.fir.txt
Expand Up @@ -15,5 +15,5 @@ FILE fqName:<root> fileName:/kt47245.kt
CALL 'public final fun next (): kotlin.Int [operator] declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT
$this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator [val] declared in <root>.test' type=kotlin.collections.IntIterator origin=null
BLOCK type=kotlin.Unit origin=null
FUN name:x visibility:local modality:FINAL <> () returnType:kotlin.Unit
FUN LOCAL_FUNCTION name:x visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
Expand Up @@ -27,7 +27,7 @@ FILE fqName:<root> fileName:/variableAsFunctionCallWithGenerics.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-kt26531Val> <T> (): kotlin.Function0<T of <root>.<get-kt26531Val>> declared in <root>'
FUN_EXPR type=kotlin.Function0<T of <root>.<get-kt26531Val>> origin=LAMBDA
FUN name:<no name provided> visibility:local modality:FINAL <> () returnType:T of <root>.<get-kt26531Val>
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<no name provided> visibility:local modality:FINAL <> () returnType:T of <root>.<get-kt26531Val>
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <no name provided> (): T of <root>.<get-kt26531Val> declared in <root>.<get-kt26531Val>'
GET_VAR '<this>: T of <root>.<get-kt26531Val> declared in <root>.<get-kt26531Val>' type=T of <root>.<get-kt26531Val> origin=null
Expand Down
Expand Up @@ -3,7 +3,7 @@ FILE fqName:<root> fileName:/anonymousFunction.kt
FIELD PROPERTY_BACKING_FIELD name:anonymous type:kotlin.Function0<kotlin.Unit> visibility:private [final,static]
EXPRESSION_BODY
FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN name:<no name provided> visibility:local modality:FINAL <> () returnType:kotlin.Unit
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<no name provided> 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:<get-anonymous> visibility:public modality:FINAL <> () returnType:kotlin.Function0<kotlin.Unit>
Expand Down
2 changes: 1 addition & 1 deletion compiler/testData/ir/irText/lambdas/localFunction.fir.txt
Expand Up @@ -3,7 +3,7 @@ FILE fqName:<root> fileName:/localFunction.kt
BLOCK_BODY
VAR name:x type:kotlin.Int [var]
CONST Int type=kotlin.Int value=0
FUN name:local visibility:local modality:FINAL <> () returnType:kotlin.Unit
FUN LOCAL_FUNCTION name:local visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
GET_VAR 'var x: kotlin.Int [var] declared in <root>.outer' type=kotlin.Int origin=null
Expand Down

0 comments on commit bd15d1c

Please sign in to comment.