Extract Function: Simplify computation of return type by pseudocode instruction
This commit is contained in:
+3
-9
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user