From 103daa841fa5021aeccef1b864fe7ec952c70b43 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Mon, 23 Jun 2014 21:01:01 +0400 Subject: [PATCH] Extract Function: Simplify computation of return type by pseudocode instruction --- .../extractFunction/extractFunctionUtils.kt | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 }