diff --git a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt index 2d276e5abea..8e4bbee43e5 100644 --- a/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt +++ b/idea/src/org/jetbrains/jet/plugin/refactoring/extractFunction/extractFunctionUtils.kt @@ -87,16 +87,10 @@ private fun List.getResultType( options: ExtractionOptions): JetType { fun instructionToType(instruction: Instruction): JetType? { val expression = when (instruction) { - is ReturnValueInstruction -> { + is ReturnValueInstruction -> (instruction.element as JetReturnExpression).getReturnedExpression() - } - is CallInstruction -> { - val callElement = instruction.resolvedCall.getCall().getCallElement() as? JetExpression - if (callElement is JetSimpleNameExpression) callElement.getParentByType(javaClass(), true) else callElement - } - is ReadValueInstruction, is OperationInstruction -> { - (instruction as JetElementInstruction).element as? JetExpression - } + is InstructionWithValue -> + instruction.outputValue?.element as? JetExpression else -> null }