Cleanup: apply "lift out..." inspection (+ some others)

This commit is contained in:
Mikhail Glukhikh
2017-06-28 14:30:52 +03:00
committed by Mikhail Glukhikh
parent 0c41ceea9d
commit 9c06739594
52 changed files with 294 additions and 311 deletions
@@ -65,11 +65,11 @@ class ConstAndJvmFieldPropertiesLowering : IrElementTransformerVoid(), FileLower
val property = descriptor.correspondingProperty
if (JvmCodegenUtil.isConstOrHasJvmFieldAnnotation(property)) {
if (descriptor is PropertyGetterDescriptor) {
return substituteGetter(descriptor, expression)
return if (descriptor is PropertyGetterDescriptor) {
substituteGetter(descriptor, expression)
}
else {
return substituteSetter(descriptor, expression)
substituteSetter(descriptor, expression)
}
}
else if (property is SyntheticJavaPropertyDescriptor) {
@@ -141,23 +141,23 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta
}
private fun generateWhenBody(expression: KtWhenExpression, irSubject: IrVariable?, irWhen: IrWhen): IrExpression {
if (irSubject == null) {
return if (irSubject == null) {
if (irWhen.branches.isEmpty())
return IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrStatementOrigin.WHEN)
IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrStatementOrigin.WHEN)
else
return irWhen
irWhen
}
else {
if (irWhen.branches.isEmpty()) {
val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrStatementOrigin.WHEN)
irBlock.statements.add(irSubject)
return irBlock
irBlock
}
else {
val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irWhen.type, IrStatementOrigin.WHEN)
irBlock.statements.add(irSubject)
irBlock.statements.add(irWhen)
return irBlock
irBlock
}
}
}