Extract Function: Simplify computation of return type by pseudocode instruction

This commit is contained in:
Alexey Sedunov
2014-06-23 21:01:01 +04:00
parent 44e41c5d96
commit 103daa841f
@@ -87,16 +87,10 @@ private fun List<Instruction>.getResultType(
options: ExtractionOptions): JetType { options: ExtractionOptions): JetType {
fun instructionToType(instruction: Instruction): JetType? { fun instructionToType(instruction: Instruction): JetType? {
val expression = when (instruction) { val expression = when (instruction) {
is ReturnValueInstruction -> { is ReturnValueInstruction ->
(instruction.element as JetReturnExpression).getReturnedExpression() (instruction.element as JetReturnExpression).getReturnedExpression()
} is InstructionWithValue ->
is CallInstruction -> { instruction.outputValue?.element as? JetExpression
val callElement = instruction.resolvedCall.getCall().getCallElement() as? JetExpression
if (callElement is JetSimpleNameExpression) callElement.getParentByType(javaClass<JetExpression>(), true) else callElement
}
is ReadValueInstruction, is OperationInstruction -> {
(instruction as JetElementInstruction).element as? JetExpression
}
else -> null else -> null
} }