From 58873b2d7bdc61100685329baed6d4bd3139a055 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 20 May 2019 19:55:16 +0300 Subject: [PATCH] FIR resolve: set setter value-parameter type properly --- .../fir/resolve/transformers/FirBodyResolveTransformer.kt | 4 +++- compiler/testData/ir/irText/classes/initVar.fir.txt | 4 ++-- .../ir/irText/declarations/classLevelProperties.fir.txt | 8 ++++---- .../ir/irText/declarations/packageLevelProperties.fir.txt | 8 ++++---- .../ir/irText/expressions/propertyReferences.fir.txt | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index 7b81f7438a3..19d77d365a4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -938,7 +938,9 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn if (property.returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return property.compose() return withScopeCleanup(localScopes) { localScopes.addIfNotNull(primaryConstructorParametersScope) - transformVariable(property, data) + (transformVariable(property, data).single as FirProperty).apply { + setter?.let { it.valueParameters[0].transformReturnTypeRef(StoreType, property.returnTypeRef) } + }.compose() } } diff --git a/compiler/testData/ir/irText/classes/initVar.fir.txt b/compiler/testData/ir/irText/classes/initVar.fir.txt index 2afa3517c61..921c3fa1a77 100644 --- a/compiler/testData/ir/irText/classes/initVar.fir.txt +++ b/compiler/testData/ir/irText/classes/initVar.fir.txt @@ -133,10 +133,10 @@ FILE fqName: fileName:/initVar.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestInitVarWithCustomSetter' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public ' type=kotlin.Int origin=null receiver: GET_VAR ': .TestInitVarWithCustomSetter declared in .TestInitVarWithCustomSetter.' type=.TestInitVarWithCustomSetter origin=null - FUN name: visibility:public modality:FINAL <> ($this:.TestInitVarWithCustomSetter, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.TestInitVarWithCustomSetter, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.TestInitVarWithCustomSetter - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean diff --git a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt index 2db000cefa0..679f48d50b9 100644 --- a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt @@ -53,10 +53,10 @@ FILE fqName: fileName:/classLevelProperties.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:public ' type=kotlin.Int origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN name: visibility:public modality:FINAL <> ($this:.C, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> ($this:.C, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType PROPERTY name:test5 visibility:public modality:FINAL [var] @@ -70,10 +70,10 @@ FILE fqName: fileName:/classLevelProperties.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.Int visibility:public ' type=kotlin.Int origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN name: visibility:private modality:FINAL <> ($this:.C, value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:private modality:FINAL <> ($this:.C, value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [var] $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int PROPERTY name:test6 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.Int visibility:public [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt index 837477450db..5cee1f39323 100644 --- a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt @@ -38,9 +38,9 @@ FILE fqName: fileName:/packageLevelProperties.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Int visibility:public [static] ' type=kotlin.Int origin=null - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType PROPERTY name:test5 visibility:public modality:FINAL [var] @@ -52,9 +52,9 @@ FILE fqName: fileName:/packageLevelProperties.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.Int visibility:public [static] ' type=kotlin.Int origin=null - FUN name: visibility:private modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:private modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int PROPERTY name:test6 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.Int visibility:public [final,static] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt index 3ff0c4ddd72..46e7da87791 100644 --- a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt @@ -131,9 +131,9 @@ FILE fqName: fileName:/propertyReferences.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN name: visibility:public modality:FINAL <> (value:IrErrorType) returnType:kotlin.Unit + FUN name: visibility:public modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY name:varWithBackingFieldAndAccessors visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:IrErrorType + VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType PROPERTY name:test_varWithBackingFieldAndAccessors visibility:public modality:FINAL [val]