[FE] Make dynamic a suitable resulted type

This fixes a FIR-specific issue where a type variable is inferred to
Any instead of dynamic. K1 wasn't affected because of a FIR-specific
condition in ResultTypeResolver.

#KT-57962 Fixed
This commit is contained in:
Kirill Rakhman
2023-04-19 15:52:18 +02:00
committed by Space Team
parent 50841e7cb0
commit 6972391185
6 changed files with 52 additions and 1 deletions
@@ -30,7 +30,7 @@ class TrivialConstraintTypeInferenceOracle private constructor(context: TypeSyst
fun isSuitableResultedType(
resultType: KotlinTypeMarker
): Boolean {
return !resultType.typeConstructor().isNothingConstructor()
return !resultType.typeConstructor().isNothingConstructor() || (isK2 && resultType.isDynamic())
}
// It's possible to generate Nothing-like constraints inside incorporation mechanism: