[NI] Fix recording type of lambda in trace
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
233dd3ffba
commit
251a02f71d
+3
-1
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.checkers.UnderscoreChecker
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||
@@ -38,6 +39,7 @@ import org.jetbrains.kotlin.types.TypeUtils.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.expressions.CoercionStrategy.COERCION_TO_UNIT
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
@@ -250,7 +252,6 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
|
||||
newInferenceLambdaInfo?.let {
|
||||
it.lastExpressionInfo.dataFlowInfoAfter = blockReturnedType.dataFlowInfo
|
||||
return null
|
||||
}
|
||||
|
||||
return computeReturnTypeBasedOnReturnExpressions(functionLiteral, context, typeOfBodyExpression)
|
||||
@@ -290,6 +291,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
returnedExpressionTypes.addIfNotNull(typeOfBodyExpression)
|
||||
|
||||
if (returnedExpressionTypes.isEmpty()) return null
|
||||
if (returnedExpressionTypes.any { it.contains { it.constructor is TypeVariableTypeConstructor }}) return null
|
||||
return CommonSupertypes.commonSupertype(returnedExpressionTypes)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
fun test(a: Int) {
|
||||
run f@{
|
||||
if (a > 0) return@f
|
||||
else return@f <!OI;RETURN_TYPE_MISMATCH!>1<!>
|
||||
else return@f <!RETURN_TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -17,5 +17,5 @@ val b = run {
|
||||
val c = run {
|
||||
if (flag) return@run
|
||||
|
||||
return@run <!OI;RETURN_TYPE_MISMATCH!>4<!>
|
||||
return@run <!RETURN_TYPE_MISMATCH!>4<!>
|
||||
}
|
||||
Reference in New Issue
Block a user