[NI] Coerce to unit for empty lambda block
Fixes 'kt3903'
This commit is contained in:
+7
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.components.FixationOrderCalc
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.NewTypeSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ResultTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.LambdaArgumentConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewTypeVariable
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NotEnoughInformationForTypeParameter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.returnTypeOrNothing
|
||||
@@ -36,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateStatus
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
@@ -264,6 +266,11 @@ class KotlinCallCompleter(
|
||||
// todo strange code -- why top-level kotlinCall? may be it isn't right outer call
|
||||
CheckArguments.checkArgument(topLevelCallContext, topLevelCall, c.getBuilder(), innerCall, lambda.returnType.let(::substitute))
|
||||
}
|
||||
|
||||
if (lambda.resultArguments.isEmpty()) {
|
||||
val unitType = lambda.returnType.builtIns.unitType
|
||||
c.getBuilder().addSubtypeConstraint(lambda.returnType.let(::substitute), unitType, LambdaArgumentConstraintPosition(lambda))
|
||||
}
|
||||
}
|
||||
|
||||
private fun canWeAnalyzeIt(c: Context, lambda: ResolvedLambdaArgument): Boolean {
|
||||
|
||||
+5
@@ -43,6 +43,11 @@ class FixVariableConstraintPosition(val variable: NewTypeVariable) : ConstraintP
|
||||
class KnownTypeParameterConstraintPosition(val typeArgument: KotlinType) : ConstraintPosition() {
|
||||
override fun toString() = "TypeArgument $typeArgument"
|
||||
}
|
||||
class LambdaArgumentConstraintPosition(val lambdaArgument: ResolvedLambdaArgument) : ConstraintPosition() {
|
||||
override fun toString(): String {
|
||||
return "LambdaArgument $lambdaArgument"
|
||||
}
|
||||
}
|
||||
|
||||
class IncorporationConstraintPosition(val from: ConstraintPosition, val initialConstraint: InitialConstraint) : ConstraintPosition() {
|
||||
override fun toString() = "Incorporate $initialConstraint from position $from"
|
||||
|
||||
Reference in New Issue
Block a user