[FIR2IR] Provide receivers also for property callable references
This commit is contained in:
+16
-1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.expressions.IrErrorCallExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
|
||||
@@ -55,7 +56,11 @@ internal class CallGenerator(
|
||||
symbol.owner.backingField?.symbol,
|
||||
symbol.owner.getter?.symbol,
|
||||
symbol.owner.setter?.symbol
|
||||
)
|
||||
).apply {
|
||||
if (callableReferenceAccess.explicitReceiver !is FirResolvedQualifier) {
|
||||
applyReceivers(callableReferenceAccess)
|
||||
}
|
||||
}
|
||||
}
|
||||
is IrFunctionSymbol -> {
|
||||
IrFunctionReferenceImpl(
|
||||
@@ -359,6 +364,16 @@ internal class CallGenerator(
|
||||
}
|
||||
this
|
||||
}
|
||||
is IrNoArgumentsCallableReferenceBase -> {
|
||||
val ownerPropertyGetter = (symbol.owner as? IrProperty)?.getter
|
||||
if (ownerPropertyGetter?.dispatchReceiverParameter != null) {
|
||||
dispatchReceiver = qualifiedAccess.findIrDispatchReceiver()
|
||||
}
|
||||
if (ownerPropertyGetter?.extensionReceiverParameter != null) {
|
||||
extensionReceiver = qualifiedAccess.findIrExtensionReceiver()
|
||||
}
|
||||
this
|
||||
}
|
||||
is IrFieldExpressionBase -> {
|
||||
val ownerField = symbol.owner
|
||||
if (!ownerField.isStatic) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
open class A {
|
||||
var f: String = "OK"
|
||||
}
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// TODO: investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
class Generic<P : Any>(val p: P)
|
||||
|
||||
class Host {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
val String?.ok: String
|
||||
get() = "OK"
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
fun box(): String {
|
||||
val f = "kotlin"::length
|
||||
val result = f.get()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
//WITH_RUNTIME
|
||||
|
||||
fun box(): String {
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_REFLECT
|
||||
import kotlin.reflect.KProperty0
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
// FULL_JDK
|
||||
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int) {
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Z(val x: Int)
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
inline class Z(val x: Int)
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
open class Foo {
|
||||
|
||||
+4
@@ -63,6 +63,8 @@ FILE fqName:<root> fileName:/memberExtension.kt
|
||||
$receiver: CONST String type=kotlin.String value="K"
|
||||
host: GET_VAR '<this>: <root>.Host declared in <root>.Host' type=<root>.Host origin=null
|
||||
p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun <get-plusK> (): kotlin.String declared in <root>.Host' setter=null type=kotlin.reflect.KProperty<*> origin=null
|
||||
$this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Host
|
||||
$receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Host
|
||||
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-plusK> visibility:public modality:FINAL <> ($this:<root>.Host, $receiver:kotlin.String) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:plusK visibility:public modality:FINAL [delegated,val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Host
|
||||
@@ -74,6 +76,8 @@ FILE fqName:<root> fileName:/memberExtension.kt
|
||||
receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Host
|
||||
receiver: ERROR_CALL 'Unresolved reference: this@R|/Host.plusK|' type=kotlin.String
|
||||
p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field='FIELD PROPERTY_DELEGATE name:plusK$delegate type:<root>.Host.StringDelegate visibility:private [final]' getter='public final fun <get-plusK> (): kotlin.String declared in <root>.Host' setter=null type=kotlin.reflect.KProperty<*> origin=null
|
||||
$this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Host
|
||||
$receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=<root>.Host
|
||||
PROPERTY name:ok visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:ok type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
|
||||
@@ -49,6 +49,7 @@ FILE fqName:<root> fileName:/boundCallableReferences.kt
|
||||
FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.reflect.KProperty0<kotlin.Int> visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
PROPERTY_REFERENCE 'public final bar: kotlin.Int [val]' field='FIELD PROPERTY_BACKING_FIELD name:bar type:kotlin.Int visibility:private [final]' getter='public final fun <get-bar> (): kotlin.Int declared in <root>.A' setter=null type=kotlin.reflect.KProperty0<kotlin.Int> origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A' type=<root>.A origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test2> visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty0<kotlin.Int>
|
||||
correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
|
||||
+1
@@ -38,6 +38,7 @@ FILE fqName:test fileName:/importedFromObject.kt
|
||||
FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KProperty0<kotlin.String> visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
PROPERTY_REFERENCE 'public final a: kotlin.String [val]' field='FIELD PROPERTY_BACKING_FIELD name:a type:kotlin.String visibility:private [final]' getter='public final fun <get-a> (): kotlin.String declared in test.Foo' setter=null type=kotlin.reflect.KProperty0<kotlin.String> origin=null
|
||||
$this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test1> visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty0<kotlin.String>
|
||||
correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -64,6 +64,9 @@ FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
p: PROPERTY_REFERENCE 'public final y: T of <root>.<get-y> [var]' field=null getter='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>' setter='public final fun <set-y> <T> (v: T of <root>.<get-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
|
||||
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (x: T of <root>.C) [primary] declared in <root>.C' type=<root>.C<kotlin.String> origin=null
|
||||
<class: T>: kotlin.String
|
||||
x: CONST String type=kotlin.String value="abc"
|
||||
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
@@ -71,3 +74,5 @@ FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
|
||||
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
p: PROPERTY_REFERENCE 'public final y: T of <root>.<get-y> [var]' field=null getter='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>' setter='public final fun <set-y> <T> (v: T of <root>.<get-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
|
||||
$receiver: TYPE_OP type=<root>.C<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.C<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
|
||||
|
||||
Reference in New Issue
Block a user