psi2ir: Provide substituted descriptor for property references
This commit is contained in:
+5
@@ -1616,6 +1616,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
|||||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericPropertyReferenceType.kt")
|
||||||
|
public void testGenericPropertyReferenceType() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("intersectionType1_NI.kt")
|
@TestMetadata("intersectionType1_NI.kt")
|
||||||
public void testIntersectionType1_NI() throws Exception {
|
public void testIntersectionType1_NI() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
||||||
|
|||||||
+1
@@ -143,6 +143,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
|||||||
return IrPropertyReferenceImpl(
|
return IrPropertyReferenceImpl(
|
||||||
startOffset, endOffset, type.toIrType(),
|
startOffset, endOffset, type.toIrType(),
|
||||||
context.symbolTable.referenceProperty(originalProperty),
|
context.symbolTable.referenceProperty(originalProperty),
|
||||||
|
propertyDescriptor,
|
||||||
propertyDescriptor.typeParametersCount,
|
propertyDescriptor.typeParametersCount,
|
||||||
getFieldForPropertyReference(originalProperty),
|
getFieldForPropertyReference(originalProperty),
|
||||||
originalGetter?.let { context.symbolTable.referenceSimpleFunction(it) },
|
originalGetter?.let { context.symbolTable.referenceSimpleFunction(it) },
|
||||||
|
|||||||
+17
-3
@@ -31,6 +31,7 @@ class IrPropertyReferenceImpl(
|
|||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
type: IrType,
|
type: IrType,
|
||||||
override val symbol: IrPropertySymbol,
|
override val symbol: IrPropertySymbol,
|
||||||
|
override val descriptor: PropertyDescriptor,
|
||||||
typeArgumentsCount: Int,
|
typeArgumentsCount: Int,
|
||||||
override val field: IrFieldSymbol?,
|
override val field: IrFieldSymbol?,
|
||||||
override val getter: IrSimpleFunctionSymbol?,
|
override val getter: IrSimpleFunctionSymbol?,
|
||||||
@@ -40,6 +41,22 @@ class IrPropertyReferenceImpl(
|
|||||||
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArgumentsCount, origin),
|
IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArgumentsCount, origin),
|
||||||
IrPropertyReference {
|
IrPropertyReference {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
type: IrType,
|
||||||
|
symbol: IrPropertySymbol,
|
||||||
|
typeArgumentsCount: Int,
|
||||||
|
field: IrFieldSymbol?,
|
||||||
|
getter: IrSimpleFunctionSymbol?,
|
||||||
|
setter: IrSimpleFunctionSymbol?,
|
||||||
|
origin: IrStatementOrigin? = null
|
||||||
|
) : this(
|
||||||
|
startOffset, endOffset, type,
|
||||||
|
symbol, symbol.descriptor,
|
||||||
|
typeArgumentsCount, field, getter, setter, origin
|
||||||
|
)
|
||||||
|
|
||||||
@Deprecated(message = "Don't use descriptor-based API for IrPropertyReference", level = DeprecationLevel.WARNING)
|
@Deprecated(message = "Don't use descriptor-based API for IrPropertyReference", level = DeprecationLevel.WARNING)
|
||||||
constructor(
|
constructor(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
@@ -57,9 +74,6 @@ class IrPropertyReferenceImpl(
|
|||||||
typeArgumentsCount, field, getter, setter, origin
|
typeArgumentsCount, field, getter, setter, origin
|
||||||
)
|
)
|
||||||
|
|
||||||
override val descriptor: PropertyDescriptor
|
|
||||||
get() = symbol.descriptor
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
visitor.visitPropertyReference(this, data)
|
visitor.visitPropertyReference(this, data)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
|
||||||
|
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: superTypes:[]
|
||||||
|
CONSTRUCTOR visibility:public <> (x:T of <uninitialized parent>) returnType:<root>.C<T of <uninitialized parent>> [primary]
|
||||||
|
VALUE_PARAMETER name:x index:0 type:T of <uninitialized parent>
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||||
|
PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'x: T of <uninitialized parent> declared in <root>.C.<init>' type=T of <uninitialized parent> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.C) returnType:T of <root>.C
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='public final fun <get-x> (): T of <root>.C declared in <root>.C'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public ' type=T of <root>.C origin=null
|
||||||
|
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<get-x>' type=<root>.C origin=null
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-x> visibility:public modality:FINAL <> ($this:<root>.C, <set-?>:T of <root>.C) returnType:kotlin.Unit
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||||
|
VALUE_PARAMETER name:<set-?> index:0 type:T of <root>.C
|
||||||
|
BLOCK_BODY
|
||||||
|
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public ' type=kotlin.Unit origin=null
|
||||||
|
receiver: GET_VAR '<this>: <root>.C declared in <root>.C.<set-x>' type=<root>.C origin=null
|
||||||
|
value: GET_VAR '<set-?>: T of <root>.C declared in <root>.C.<set-x>' type=T of <root>.C origin=null
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
FUN name:<get-y> visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||||
|
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='public final fun <get-y> (): IrErrorType declared in <root>'
|
||||||
|
ERROR_CALL 'Unresolved reference: <Unresolved name: x>#' type=IrErrorType
|
||||||
|
FUN name:<set-y> visibility:public modality:FINAL <> (v:IrErrorType) returnType:kotlin.Unit
|
||||||
|
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
VALUE_PARAMETER name:v index:0 type:IrErrorType
|
||||||
|
BLOCK_BODY
|
||||||
|
ERROR_CALL 'Unresolved reference: <Unresolved name: x>#' type=IrErrorType
|
||||||
|
FUN name:use visibility:public modality:FINAL <> (p:kotlin.reflect.KMutableProperty<kotlin.String>) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:p index:0 type:kotlin.reflect.KMutableProperty<kotlin.String>
|
||||||
|
BLOCK_BODY
|
||||||
|
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||||
|
BLOCK_BODY
|
||||||
|
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||||
|
p: CALL 'public final fun <get-y> (): IrErrorType declared in <root>' type=IrErrorType origin=null
|
||||||
|
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||||
|
BLOCK_BODY
|
||||||
|
TYPE_OP type=<root>.C<kotlin.String> origin=CAST typeOperand=<root>.C<kotlin.String>
|
||||||
|
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: ERROR_CALL 'Unresolved reference: <Inapplicable(WRONG_RECEIVER): [/y]>#' type=IrErrorType
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import kotlin.reflect.KMutableProperty
|
||||||
|
|
||||||
|
class C<T>(var x: T)
|
||||||
|
|
||||||
|
var <T> C<T>.y
|
||||||
|
get() = x
|
||||||
|
set(v) {
|
||||||
|
x = v
|
||||||
|
}
|
||||||
|
|
||||||
|
fun use(p: KMutableProperty<String>) {}
|
||||||
|
|
||||||
|
fun test1() {
|
||||||
|
use(C("abc")::y)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test2(a: Any) {
|
||||||
|
a as C<String>
|
||||||
|
use(a::y)
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
|
||||||
|
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||||
|
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C<T of <root>.C>
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||||
|
CONSTRUCTOR visibility:public <> (x:T of <root>.C) returnType:<root>.C<T of <root>.C> [primary]
|
||||||
|
VALUE_PARAMETER name:x index:0 type:T of <root>.C
|
||||||
|
BLOCK_BODY
|
||||||
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||||
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||||
|
PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public
|
||||||
|
EXPRESSION_BODY
|
||||||
|
GET_VAR 'x: T of <root>.C declared in <root>.C.<init>' type=T of <root>.C origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.C<T of <root>.C>) returnType:T of <root>.C
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.C>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='public final fun <get-x> (): T of <root>.C declared in <root>.C'
|
||||||
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public ' type=T of <root>.C origin=null
|
||||||
|
receiver: GET_VAR '<this>: <root>.C<T of <root>.C> declared in <root>.C.<get-x>' type=<root>.C<T of <root>.C> origin=null
|
||||||
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-x> visibility:public modality:FINAL <> ($this:<root>.C<T of <root>.C>, <set-?>:T of <root>.C) returnType:kotlin.Unit
|
||||||
|
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.C>
|
||||||
|
VALUE_PARAMETER name:<set-?> index:0 type:T of <root>.C
|
||||||
|
BLOCK_BODY
|
||||||
|
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:public ' type=kotlin.Unit origin=null
|
||||||
|
receiver: GET_VAR '<this>: <root>.C<T of <root>.C> declared in <root>.C.<set-x>' type=<root>.C<T of <root>.C> origin=null
|
||||||
|
value: GET_VAR '<set-?>: T of <root>.C declared in <root>.C.<set-x>' type=T of <root>.C origin=null
|
||||||
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
|
||||||
|
overridden:
|
||||||
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||||
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int
|
||||||
|
overridden:
|
||||||
|
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String
|
||||||
|
overridden:
|
||||||
|
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||||
|
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||||
|
PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
FUN name:<get-y> visibility:public modality:FINAL <T> ($receiver:<root>.C<T of <root>.<get-y>>) returnType:T of <root>.<get-y>
|
||||||
|
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||||
|
$receiver: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.<get-y>>
|
||||||
|
BLOCK_BODY
|
||||||
|
RETURN type=kotlin.Nothing from='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>'
|
||||||
|
CALL 'public final fun <get-x> (): T of <root>.C declared in <root>.C' type=T of <root>.<get-y> origin=GET_PROPERTY
|
||||||
|
$this: GET_VAR '<this>: <root>.C<T of <root>.<get-y>> declared in <root>.<get-y>' type=<root>.C<T of <root>.<get-y>> origin=null
|
||||||
|
FUN name:<set-y> visibility:public modality:FINAL <T> ($receiver:<root>.C<T of <root>.<set-y>>, v:T of <root>.<set-y>) returnType:kotlin.Unit
|
||||||
|
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
|
||||||
|
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||||
|
$receiver: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.<set-y>>
|
||||||
|
VALUE_PARAMETER name:v index:0 type:T of <root>.<set-y>
|
||||||
|
BLOCK_BODY
|
||||||
|
CALL 'public final fun <set-x> (<set-?>: T of <root>.C): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=EQ
|
||||||
|
$this: GET_VAR '<this>: <root>.C<T of <root>.<set-y>> declared in <root>.<set-y>' type=<root>.C<T of <root>.<set-y>> origin=null
|
||||||
|
<set-?>: GET_VAR 'v: T of <root>.<set-y> declared in <root>.<set-y>' type=T of <root>.<set-y> origin=null
|
||||||
|
FUN name:use visibility:public modality:FINAL <> (p:kotlin.reflect.KMutableProperty<kotlin.String>) returnType:kotlin.Unit
|
||||||
|
VALUE_PARAMETER name:p index:0 type:kotlin.reflect.KMutableProperty<kotlin.String>
|
||||||
|
BLOCK_BODY
|
||||||
|
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||||
|
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>.<set-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
|
||||||
|
<1>: kotlin.String
|
||||||
|
$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
|
||||||
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
|
TYPE_OP type=<root>.C<kotlin.String> origin=CAST typeOperand=<root>.C<kotlin.String>
|
||||||
|
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>.<set-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
|
||||||
|
<1>: kotlin.String
|
||||||
|
$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
|
||||||
@@ -1616,6 +1616,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
|||||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericPropertyReferenceType.kt")
|
||||||
|
public void testGenericPropertyReferenceType() throws Exception {
|
||||||
|
runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("intersectionType1_NI.kt")
|
@TestMetadata("intersectionType1_NI.kt")
|
||||||
public void testIntersectionType1_NI() throws Exception {
|
public void testIntersectionType1_NI() throws Exception {
|
||||||
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user