FIR2IR: set extension receiver for anonymous functions
This commit is contained in:
+17
-17
@@ -297,23 +297,23 @@ class Fir2IrDeclarationStorage(
|
||||
for ((index, typeParameter) in function.typeParameters.withIndex()) {
|
||||
typeParameters += getIrTypeParameter(typeParameter, index).apply { this.parent = parent }
|
||||
}
|
||||
val receiverTypeRef = function.receiverTypeRef
|
||||
if (receiverTypeRef != null) {
|
||||
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
|
||||
val type = receiverTypeRef.toIrType(session, this@Fir2IrDeclarationStorage)
|
||||
val receiverDescriptor = WrappedReceiverParameterDescriptor()
|
||||
irSymbolTable.declareValueParameter(
|
||||
startOffset, endOffset, thisOrigin,
|
||||
receiverDescriptor, type
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, type,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
).apply {
|
||||
this.parent = parent
|
||||
receiverDescriptor.bind(this)
|
||||
}
|
||||
}
|
||||
val receiverTypeRef = function?.receiverTypeRef
|
||||
if (receiverTypeRef != null) {
|
||||
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
|
||||
val type = receiverTypeRef.toIrType(session, this@Fir2IrDeclarationStorage)
|
||||
val receiverDescriptor = WrappedReceiverParameterDescriptor()
|
||||
irSymbolTable.declareValueParameter(
|
||||
startOffset, endOffset, thisOrigin,
|
||||
receiverDescriptor, type
|
||||
) { symbol ->
|
||||
IrValueParameterImpl(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), -1, type,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false
|
||||
).apply {
|
||||
this.parent = parent
|
||||
receiverDescriptor.bind(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
|
||||
@@ -21,8 +21,9 @@ FILE fqName:<root> fileName:/initValInLambda.kt
|
||||
<R>: kotlin.Nothing
|
||||
$receiver: CONST Int type=kotlin.Int value=1
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Int, kotlin.Nothing> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($this:<root>.TestInitValInLambdaCalledOnce) returnType:kotlin.Nothing
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($this:<root>.TestInitValInLambdaCalledOnce, $receiver:kotlin.Int) returnType:kotlin.Nothing
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.TestInitValInLambdaCalledOnce
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.TestInitValInLambdaCalledOnce declared in <root>.TestInitValInLambdaCalledOnce' type=<root>.TestInitValInLambdaCalledOnce origin=null
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ FILE fqName:<root> fileName:/lambdaInDataClassDefaultParameter.kt
|
||||
VALUE_PARAMETER name:runA index:0 type:kotlin.Function2<<root>.A, kotlin.String, kotlin.Unit>
|
||||
EXPRESSION_BODY
|
||||
FUN_EXPR type=kotlin.Function2<<root>.A, kotlin.String, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.String) returnType:kotlin.Unit
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.A, it:kotlin.String) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.String
|
||||
BLOCK_BODY
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
|
||||
@@ -16,7 +16,8 @@ FILE fqName:<root> fileName:/lambdas.kt
|
||||
FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function2<kotlin.Any, kotlin.Any, kotlin.Any> visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
FUN_EXPR type=kotlin.Function2<kotlin.Any, kotlin.Any, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Int
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.Any, it:kotlin.Any) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||
|
||||
@@ -7,7 +7,8 @@ FILE fqName:<root> fileName:/extensionLambda.kt
|
||||
<R>: kotlin.Int
|
||||
$receiver: CONST String type=kotlin.String value="42"
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun <get-length> (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null
|
||||
$this: ERROR_CALL 'Unresolved reference: this@R|special/anonymous|' type=kotlin.String
|
||||
$this: GET_VAR '<this>: kotlin.String declared in <no parent>.<anonymous>' type=kotlin.String origin=null
|
||||
|
||||
@@ -89,21 +89,24 @@ FILE fqName:<root> fileName:/multipleImplicitReceivers.kt
|
||||
<R>: kotlin.Int
|
||||
receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.A
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.A, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.A) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.A
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun with <T, R> (receiver: T of kotlin.with, block: kotlin.Function1<T of kotlin.with, R of kotlin.with>): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null
|
||||
<T>: <root>.IFoo
|
||||
<R>: kotlin.Int
|
||||
receiver: GET_VAR 'fooImpl: <root>.IFoo declared in <root>.test' type=<root>.IFoo origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.IFoo, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IFoo) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.IFoo
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun with <T, R> (receiver: T of kotlin.with, block: kotlin.Function1<T of kotlin.with, R of kotlin.with>): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null
|
||||
<T>: <root>.IInvoke
|
||||
<R>: kotlin.Int
|
||||
receiver: GET_VAR 'invokeImpl: <root>.IInvoke declared in <root>.test' type=<root>.IInvoke origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<<root>.IInvoke, kotlin.Int> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:<root>.IInvoke) returnType:kotlin.Int
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.IInvoke
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun invoke (): kotlin.Int [operator] declared in <root>.IInvoke' type=kotlin.Int origin=null
|
||||
$this: ERROR_CALL 'Unresolved reference: this@R|special/anonymous|' type=<root>.IInvoke
|
||||
$this: GET_VAR '<this>: <root>.IInvoke declared in <no parent>.<anonymous>' type=<root>.IInvoke origin=null
|
||||
|
||||
+3
-2
@@ -23,10 +23,11 @@ FILE fqName:<root> fileName:/builtinMap.kt
|
||||
<class: V>: V1 of <root>.plus
|
||||
p0: GET_VAR '<this>: kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.collections.Map<out K1 of <root>.plus, V1 of <root>.plus> origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>
|
||||
BLOCK_BODY
|
||||
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus? [operator] declared in java.util.HashMap' type=V1 of <root>.plus? origin=null
|
||||
$this: ERROR_CALL 'Unresolved reference: this@R|special/anonymous|' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>
|
||||
$this: GET_VAR '<this>: java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> declared in <no parent>.<anonymous>' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
|
||||
p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
|
||||
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
|
||||
p1: CALL 'public final fun <get-second> (): V1 of <root>.plus declared in kotlin.Pair' type=V1 of <root>.plus origin=null
|
||||
|
||||
Reference in New Issue
Block a user