Simplify code in Fir2IrConversionScope.returnTarget

This commit is contained in:
Mikhail Glukhikh
2021-05-07 14:13:49 +03:00
parent 05872fc6a8
commit ac9e8f667d
@@ -95,21 +95,20 @@ class Fir2IrConversionScope {
} }
fun returnTarget(expression: FirReturnExpression, declarationStorage: Fir2IrDeclarationStorage): IrFunction { fun returnTarget(expression: FirReturnExpression, declarationStorage: Fir2IrDeclarationStorage): IrFunction {
val firTarget = expression.target.labeledElement val irTarget = when (val firTarget = expression.target.labeledElement) {
val irTarget = (firTarget as? FirFunction)?.let { is FirConstructor -> declarationStorage.getCachedIrConstructor(firTarget)
when (it) { is FirPropertyAccessor -> {
is FirConstructor -> declarationStorage.getCachedIrConstructor(it) var answer: IrFunction? = null
is FirPropertyAccessor -> { for ((property, firProperty) in propertyStack.asReversed()) {
for ((property, firProperty) in propertyStack.asReversed()) { if (firProperty?.getter === firTarget) {
if (firProperty?.getter === firTarget) { answer = property.getter
return@let property.getter } else if (firProperty?.setter === firTarget) {
} else if (firProperty?.setter === firTarget) { answer = property.setter
return@let property.setter
}
} }
} }
else -> declarationStorage.getCachedIrFunction(it) answer
} }
else -> declarationStorage.getCachedIrFunction(firTarget)
} }
for (potentialTarget in functionStack.asReversed()) { for (potentialTarget in functionStack.asReversed()) {
if (potentialTarget == irTarget) { if (potentialTarget == irTarget) {