[FIR2IR] Add extension receiver parameter to delegated members
This commit is contained in:
+5
-3
@@ -10,10 +10,8 @@ import org.jetbrains.kotlin.backend.common.ir.isOverridable
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities as OldVisibilities
|
||||
import org.jetbrains.kotlin.fir.Visibilities
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
|
||||
import org.jetbrains.kotlin.fir.backend.FirMetadataSource
|
||||
import org.jetbrains.kotlin.fir.backend.*
|
||||
import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter
|
||||
import org.jetbrains.kotlin.fir.backend.isOverriding
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
|
||||
@@ -233,6 +231,10 @@ internal class DelegatedMemberGenerator(
|
||||
}
|
||||
irTypeSubstitutor = IrTypeSubstitutor(substParameters, substArguments, irBuiltIns)
|
||||
}
|
||||
superFunction.extensionReceiverParameter?.let {
|
||||
val substitutedType = if (addTypeSubstitution) irTypeSubstitutor.substitute(it.type) else it.type
|
||||
extensionReceiverParameter = declareThisReceiverParameter(symbolTable, substitutedType, origin)
|
||||
}
|
||||
valueParameters = superFunction.valueParameters.map { valueParameter ->
|
||||
val parameterDescriptor = WrappedValueParameterDescriptor()
|
||||
val substedType = if (addTypeSubstitution) irTypeSubstitutor.substitute(valueParameter.type) else valueParameter.type
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
inline class S(val x: String)
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
inline class S(val x: String)
|
||||
|
||||
-1
@@ -1,6 +1,5 @@
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
inline class S(val x: String)
|
||||
|
||||
@@ -224,14 +224,16 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
|
||||
CALL 'public abstract fun bar (): kotlin.Int declared in <root>.IBase' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.bar' type=<root>.Test1 origin=null
|
||||
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test1) returnType:kotlin.Unit
|
||||
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test1, $receiver:kotlin.String) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test1
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:kotlin.String
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun qux (): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1.qux' type=<root>.Test1 origin=null
|
||||
$receiver: GET_VAR '<this>: kotlin.String declared in <root>.Test1.qux' type=kotlin.String origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
@@ -281,14 +283,16 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
|
||||
CALL 'public abstract fun bar (): kotlin.Int declared in <root>.IBase' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.bar' type=<root>.Test2 origin=null
|
||||
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Unit
|
||||
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <> ($this:<root>.Test2, $receiver:kotlin.String) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:kotlin.String
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun qux (): kotlin.Unit declared in <root>.IBase' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]' type=<root>.IBase origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.qux' type=<root>.Test2 origin=null
|
||||
$receiver: GET_VAR '<this>: kotlin.String declared in <root>.Test2.qux' type=kotlin.String origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.IBase visibility:local [final]
|
||||
PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val]
|
||||
FUN DELEGATED_MEMBER name:<get-x> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.String
|
||||
@@ -324,37 +328,43 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-y>' type=<root>.Test2 origin=null
|
||||
<set-?>: GET_VAR '<set-?>: kotlin.Int declared in <root>.Test2.<set-y>' type=kotlin.Int origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val]
|
||||
FUN DELEGATED_MEMBER name:<get-z1> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
|
||||
FUN DELEGATED_MEMBER name:<get-z1> visibility:public modality:OPEN <> ($this:<root>.Test2, $receiver:kotlin.Byte) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z1 visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public abstract fun <get-z1> (): kotlin.Int declared in <root>.IOther
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:kotlin.Byte
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun <get-z1> (): kotlin.Int declared in <root>.Test2'
|
||||
CALL 'public abstract fun <get-z1> (): kotlin.Int declared in <root>.IOther' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-z1>' type=<root>.Test2 origin=null
|
||||
$receiver: GET_VAR '<this>: kotlin.Byte declared in <root>.Test2.<get-z1>' type=kotlin.Byte origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
|
||||
FUN DELEGATED_MEMBER name:<get-z2> visibility:public modality:OPEN <> ($this:<root>.Test2) returnType:kotlin.Int
|
||||
FUN DELEGATED_MEMBER name:<get-z2> visibility:public modality:OPEN <> ($this:<root>.Test2, $receiver:kotlin.Byte) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
|
||||
overridden:
|
||||
public abstract fun <get-z2> (): kotlin.Int declared in <root>.IOther
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:kotlin.Byte
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun <get-z2> (): kotlin.Int declared in <root>.Test2'
|
||||
CALL 'public abstract fun <get-z2> (): kotlin.Int declared in <root>.IOther' type=kotlin.Int origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<get-z2>' type=<root>.Test2 origin=null
|
||||
FUN DELEGATED_MEMBER name:<set-z2> visibility:public modality:OPEN <> ($this:<root>.Test2, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
$receiver: GET_VAR '<this>: kotlin.Byte declared in <root>.Test2.<get-z2>' type=kotlin.Byte origin=null
|
||||
FUN DELEGATED_MEMBER name:<set-z2> visibility:public modality:OPEN <> ($this:<root>.Test2, $receiver:kotlin.Byte, <set-?>:kotlin.Int) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var]
|
||||
overridden:
|
||||
public abstract fun <set-z2> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test2
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:kotlin.Byte
|
||||
VALUE_PARAMETER DELEGATED_MEMBER name:<set-?> index:0 type:kotlin.Int
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun <set-z2> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.IOther' type=kotlin.Unit origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:<root>.IOther visibility:local [final]' type=<root>.IOther origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2.<set-z2>' type=<root>.Test2 origin=null
|
||||
$receiver: GET_VAR '<this>: kotlin.Byte declared in <root>.Test2.<set-z2>' type=kotlin.Byte origin=null
|
||||
<set-?>: GET_VAR '<set-?>: kotlin.Int declared in <root>.Test2.<set-z2>' type=kotlin.Int origin=null
|
||||
FIELD DELEGATE name:<$$delegate_1> type:<root>.IOther visibility:local [final]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
|
||||
@@ -34,18 +34,20 @@ FILE fqName:<root> fileName:/kt35550.kt
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A' type=<root>.A origin=null
|
||||
value: GET_VAR 'i: <root>.I declared in <root>.A.<init>' type=<root>.I origin=null
|
||||
PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
|
||||
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <T> ($this:<root>.A) returnType:T of <root>.I.<get-id>
|
||||
FUN DELEGATED_MEMBER name:<get-id> visibility:public modality:OPEN <T> ($this:<root>.A, $receiver:T of <root>.A.<get-id>) returnType:T of <root>.I.<get-id>
|
||||
correspondingProperty: PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val]
|
||||
overridden:
|
||||
public open fun <get-id> <T> (): T of <root>.I.<get-id> declared in <root>.I
|
||||
TYPE_PARAMETER DELEGATED_MEMBER name:T index:0 variance: superTypes:[]
|
||||
TYPE_PARAMETER DELEGATED_MEMBER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.A
|
||||
$receiver: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:T of <root>.A.<get-id>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun <get-id> <T> (): T of <root>.I.<get-id> declared in <root>.A'
|
||||
CALL 'public open fun <get-id> <T> (): T of <root>.I.<get-id> declared in <root>.I' type=T of <root>.A.<get-id> origin=null
|
||||
<T>: <none>
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.I visibility:local [final]' type=<root>.I origin=null
|
||||
receiver: GET_VAR '<this>: <root>.A declared in <root>.A.<get-id>' type=<root>.A origin=null
|
||||
$receiver: GET_VAR '<this>: T of <root>.A.<get-id> declared in <root>.A.<get-id>' type=T of <root>.A.<get-id> origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.I visibility:local [final]
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ FILE fqName:<root> fileName:/delegatedMembers.kt
|
||||
FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN <X> ($this:<root>.Test<TT of <root>.Test>, t:TT of <root>.Test, x:X of <root>.Test.qux) returnType:kotlin.Unit
|
||||
overridden:
|
||||
public abstract fun qux <X> (t: T of <root>.IBase, x: X of <root>.IBase.qux): kotlin.Unit declared in <root>.IBase
|
||||
TYPE_PARAMETER DELEGATED_MEMBER name:X index:0 variance: superTypes:[]
|
||||
TYPE_PARAMETER DELEGATED_MEMBER name:X index:0 variance: superTypes:[kotlin.Any?]
|
||||
$this: VALUE_PARAMETER DELEGATED_MEMBER name:<this> type:<root>.Test<TT of <root>.Test>
|
||||
VALUE_PARAMETER DELEGATED_MEMBER name:t index:0 type:TT of <root>.Test
|
||||
VALUE_PARAMETER DELEGATED_MEMBER name:x index:1 type:X of <root>.Test.qux
|
||||
|
||||
Reference in New Issue
Block a user