From aa4a0426122fed1f25230497c4db8f9147da425c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 6 Oct 2020 13:27:30 +0300 Subject: [PATCH] [FIR2IR] Use deepest matching symbol also for synthetic properties #KT-42359 Fixed --- .../kotlin/fir/backend/ConversionUtils.kt | 7 +- .../javaBox.kt | 1 - .../irText/firProblems/AllCandidates.fir.txt | 79 +++++++++++++++++++ 3 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 61ec62e1e1a..f9385aba0a9 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -143,11 +143,12 @@ private fun FirCallableSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationS is FirFunctionSymbol<*> -> declarationStorage.getIrFunctionSymbol(this) is SyntheticPropertySymbol -> { (fir as? FirSyntheticProperty)?.let { syntheticProperty -> - if (preferGetter) { - syntheticProperty.getter.delegate.symbol.toSymbol(declarationStorage, preferGetter) + val delegateSymbol = if (preferGetter) { + syntheticProperty.getter.delegate.symbol } else { - syntheticProperty.setter!!.delegate.symbol.toSymbol(declarationStorage, preferGetter) + syntheticProperty.setter!!.delegate.symbol } + delegateSymbol.deepestMatchingOverriddenSymbol().toSymbol(declarationStorage, preferGetter) } ?: declarationStorage.getIrPropertySymbol(this) } is FirPropertySymbol -> declarationStorage.getIrPropertySymbol(this) diff --git a/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/javaBox.kt b/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/javaBox.kt index 5ef670346b1..22aa3de2bd7 100644 --- a/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/javaBox.kt +++ b/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/javaBox.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: Box.java diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt b/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt new file mode 100644 index 00000000000..f0afc80228e --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt @@ -0,0 +1,79 @@ +FILE fqName: fileName:/AllCandidates.kt + CLASS CLASS name:ResolvedCall modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ResolvedCall.ResolvedCall> + TYPE_PARAMETER name:C index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.ResolvedCall.ResolvedCall> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ResolvedCall modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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 [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:MyCandidate modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyCandidate + CONSTRUCTOR visibility:public <> (resolvedCall:.ResolvedCall<*>) returnType:.MyCandidate [primary] + VALUE_PARAMETER name:resolvedCall index:0 type:.ResolvedCall<*> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyCandidate modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.ResolvedCall<*> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'resolvedCall: .ResolvedCall<*> declared in .MyCandidate.' type=.ResolvedCall<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyCandidate) returnType:.ResolvedCall<*> + correspondingProperty: PROPERTY name:resolvedCall visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.MyCandidate + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .ResolvedCall<*> declared in .MyCandidate' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resolvedCall type:.ResolvedCall<*> visibility:private [final]' type=.ResolvedCall<*> origin=null + receiver: GET_VAR ': .MyCandidate declared in .MyCandidate.' type=.MyCandidate origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: 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 [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:allCandidatesResult visibility:private modality:FINAL (allCandidates:kotlin.collections.Collection<.MyCandidate>) returnType:.OverloadResolutionResultsImpl.allCandidatesResult?>? + TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:allCandidates index:0 type:kotlin.collections.Collection<.MyCandidate> + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun allCandidatesResult (allCandidates: kotlin.collections.Collection<.MyCandidate>): .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in ' + CALL 'public final fun apply (block: @[ExtensionFunctionType] @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + : .OverloadResolutionResultsImpl.allCandidatesResult?>? + $receiver: CALL 'public open fun nameNotFound (): .OverloadResolutionResultsImpl.OverloadResolutionResultsImpl.nameNotFound?>? declared in .OverloadResolutionResultsImpl' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + : A of .allCandidatesResult? + block: FUN_EXPR type=kotlin.Function1<.OverloadResolutionResultsImpl.allCandidatesResult?>?, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.OverloadResolutionResultsImpl.allCandidatesResult?>?) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.OverloadResolutionResultsImpl.allCandidatesResult?>? + BLOCK_BODY + CALL 'public open fun setAllCandidates (allCandidates: kotlin.collections.Collection<.ResolvedCall.OverloadResolutionResultsImpl?>?>?): kotlin.Unit declared in .OverloadResolutionResultsImpl' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in .allCandidatesResult.' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null + : .MyCandidate + : .ResolvedCall.allCandidatesResult> + $receiver: GET_VAR 'allCandidates: kotlin.collections.Collection<.MyCandidate> declared in .allCandidatesResult' type=kotlin.collections.Collection<.MyCandidate> origin=null + transform: FUN_EXPR type=kotlin.Function1<.MyCandidate, .ResolvedCall.allCandidatesResult>> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.MyCandidate) returnType:.ResolvedCall.allCandidatesResult> + VALUE_PARAMETER name:it index:0 type:.MyCandidate + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .MyCandidate): .ResolvedCall.allCandidatesResult> declared in .allCandidatesResult.' + TYPE_OP type=.ResolvedCall.allCandidatesResult> origin=CAST typeOperand=.ResolvedCall.allCandidatesResult> + CALL 'public final fun (): .ResolvedCall<*> declared in .MyCandidate' type=.ResolvedCall<*> origin=GET_PROPERTY + $this: GET_VAR 'it: .MyCandidate declared in .allCandidatesResult..' type=.MyCandidate origin=null