FIR: don't add T <: Unit constraints that will only remove errors

^KT-55693 Fixed
This commit is contained in:
pyos
2023-01-02 12:17:30 +01:00
committed by Dmitriy Novozhilov
parent b6653dd872
commit 7ee1b75e43
3 changed files with 3 additions and 3 deletions
@@ -184,7 +184,7 @@ class FirCallCompleter(
)
}
}
!expectedType.isUnitOrFlexibleUnit || !mayBeCoercionToUnitApplied -> {
!expectedType.isUnitOrFlexibleUnit || (!mayBeCoercionToUnitApplied && !expectedTypeMismatchIsReportedInChecker) -> {
system.addSubtypeConstraint(initialType, expectedType, expectedTypeConstraintPosition)
}
system.notFixedTypeVariables.isEmpty() -> return
@@ -27,7 +27,7 @@ fun testResultOfAnonFun2() =
fun testReturnFromAnonFun() =
run(fun () {
return if (true) 42 else println()
return <!ARGUMENT_TYPE_MISMATCH, RETURN_TYPE_MISMATCH!>if (true) 42 else println()<!>
})
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>testReturn1<!>() =
@@ -29,5 +29,5 @@ fun example() {
return <!INVALID_IF_AS_EXPRESSION!>if<!> (true) true
}
return if (true) true else {}
return <!RETURN_TYPE_MISMATCH!>if (true) true else {}<!>
}