From 90a476deb17514d64c0bfee92ee36c82128c897f Mon Sep 17 00:00:00 2001 From: Alexandr Suhinin Date: Wed, 6 May 2020 13:54:01 +0300 Subject: [PATCH] EA-231509: dont use PsiType.NULL as a return type GitOrigin-RevId: 23f8141f25a7b1ba7779debe97002663c543be31 --- .../extractMethod/newImpl/ExtractMethodAnalyzer.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/ExtractMethodAnalyzer.kt b/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/ExtractMethodAnalyzer.kt index 6bcf59985ec2..9a1339ea0290 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/ExtractMethodAnalyzer.kt +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/ExtractMethodAnalyzer.kt @@ -146,7 +146,10 @@ private fun findOutputFromReturn(flowOutput: FlowOutput): ExpressionOutput? { val returnExpressions = flowOutput.statements .mapNotNull { statement -> (statement as? PsiReturnStatement)?.returnValue } .sortedBy { returnStatement -> returnStatement.startOffset } - val returnType = returnExpressions.asSequence().mapNotNull { expression -> expression.type }.firstOrNull() + val returnType = returnExpressions.asSequence() + .mapNotNull { expression -> expression.type } + .filterNot { type -> type == PsiType.NULL } + .firstOrNull() val variableName = returnExpressions.asSequence().map { expression -> guessName(expression) }.firstOrNull() ?: "x" val nullability = CodeFragmentAnalyzer.inferNullability(returnExpressions) return if (returnType != null) ExpressionOutput(returnType, variableName, returnExpressions, nullability) else null