From 7e4688da939485d9586be2854af0414c95a0c3a4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 19 Mar 2019 18:02:33 +0300 Subject: [PATCH] psi2ir: add test for reference to var with non-accessible setter --- .../irText/expressions/propertyReferences.kt | 10 +++ .../irText/expressions/propertyReferences.txt | 75 +++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/compiler/testData/ir/irText/expressions/propertyReferences.kt b/compiler/testData/ir/irText/expressions/propertyReferences.kt index b7c4a7585f9..23ac0e79f37 100644 --- a/compiler/testData/ir/irText/expressions/propertyReferences.kt +++ b/compiler/testData/ir/irText/expressions/propertyReferences.kt @@ -4,6 +4,13 @@ object Delegate { operator fun setValue(thisRef: Any?, kProp: Any, value: Int) {} } +open class C { + var varWithPrivateSet: Int = 1 + private set + var varWithProtectedSet: Int = 1 + protected set +} + val valWithBackingField = 1 val test_valWithBackingField = ::valWithBackingField @@ -44,6 +51,9 @@ val test_constVal = ::constVal val test_J_CONST = J::CONST val test_J_nonConst = J::nonConst +val test_varWithPrivateSet = C::varWithPrivateSet +val test_varWithProtectedSet = C::varWithProtectedSet + // FILE: J.java public class J { public static final int CONST = 1; diff --git a/compiler/testData/ir/irText/expressions/propertyReferences.txt b/compiler/testData/ir/irText/expressions/propertyReferences.txt index e2b40842e2b..10cee07de79 100644 --- a/compiler/testData/ir/irText/expressions/propertyReferences.txt +++ b/compiler/testData/ir/irText/expressions/propertyReferences.txt @@ -31,6 +31,63 @@ FILE fqName: fileName:/propertyReferences.kt overridden: FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String flags: $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS CLASS name:C modality:OPEN visibility:public flags: superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:C flags: + CONSTRUCTOR visibility:public <> () returnType:C flags:primary + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='C' + PROPERTY name:varWithPrivateSet visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:varWithPrivateSet type:kotlin.Int visibility:public flags: + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C) returnType:kotlin.Int flags: + correspondingProperty: PROPERTY name:varWithPrivateSet visibility:public modality:FINAL flags:var + $this: VALUE_PARAMETER name: type:C flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'varWithPrivateSet: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + FUN name: visibility:private modality:FINAL <> ($this:C, :kotlin.Int) returnType:kotlin.Unit flags: + correspondingProperty: PROPERTY name:varWithPrivateSet visibility:public modality:FINAL flags:var + $this: VALUE_PARAMETER name: type:C flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + BLOCK_BODY + SET_FIELD 'varWithPrivateSet: Int' type=kotlin.Unit origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null + PROPERTY name:varWithProtectedSet visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:varWithProtectedSet type:kotlin.Int visibility:public flags: + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C) returnType:kotlin.Int flags: + correspondingProperty: PROPERTY name:varWithProtectedSet visibility:public modality:FINAL flags:var + $this: VALUE_PARAMETER name: type:C flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'varWithProtectedSet: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + FUN name: visibility:protected modality:FINAL <> ($this:C, :kotlin.Int) returnType:kotlin.Unit flags: + correspondingProperty: PROPERTY name:varWithProtectedSet visibility:public modality:FINAL flags:var + $this: VALUE_PARAMETER name: type:C flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + BLOCK_BODY + SET_FIELD 'varWithProtectedSet: Int' type=kotlin.Unit origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: PROPERTY name:valWithBackingField visibility:public modality:FINAL flags:val FIELD PROPERTY_BACKING_FIELD name:valWithBackingField type:kotlin.Int visibility:public flags:final,static EXPRESSION_BODY @@ -219,3 +276,21 @@ FILE fqName: fileName:/propertyReferences.kt BLOCK_BODY RETURN type=kotlin.Nothing from='(): KMutableProperty0' GET_FIELD 'test_J_nonConst: KMutableProperty0' type=kotlin.reflect.KMutableProperty0 origin=null + PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:kotlin.reflect.KProperty1 visibility:public flags:final,static + EXPRESSION_BODY + PROPERTY_REFERENCE 'varWithPrivateSet: Int' field=null getter='(): Int' setter=null type=kotlin.reflect.KProperty1 origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty1 flags: + correspondingProperty: PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL flags:val + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): KProperty1' + GET_FIELD 'test_varWithPrivateSet: KProperty1' type=kotlin.reflect.KProperty1 origin=null + PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:kotlin.reflect.KProperty1 visibility:public flags:final,static + EXPRESSION_BODY + PROPERTY_REFERENCE 'varWithProtectedSet: Int' field=null getter='(): Int' setter=null type=kotlin.reflect.KProperty1 origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KProperty1 flags: + correspondingProperty: PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL flags:val + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): KProperty1' + GET_FIELD 'test_varWithProtectedSet: KProperty1' type=kotlin.reflect.KProperty1 origin=null