EA-231509: dont use PsiType.NULL as a return type

GitOrigin-RevId: 23f8141f25a7b1ba7779debe97002663c543be31
This commit is contained in:
Alexandr Suhinin
2020-05-06 11:00:24 +00:00
committed by intellij-monorepo-bot
parent 897ea7110a
commit 90a476deb1
@@ -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