Check if the intersecting types aren't empty during finding the result type for variable fixation

^KT-47941 Fixed
This commit is contained in:
Victor Petukhov
2021-07-28 16:49:22 +03:00
committed by teamcityserver
parent 3eaa452f9e
commit 93f9d9dacd
7 changed files with 88 additions and 1 deletions
@@ -265,7 +265,8 @@ class ResultTypeResolver(
* fun <T : String> materialize(): T = null as T
* val bar: Int = materialize() // no errors, T is inferred into String & Int
*/
intersectTypes(upperConstraints.filterNot { it.isExpectedTypePosition() }.map { it.type })
val filteredUpperConstraints = upperConstraints.filterNot { it.isExpectedTypePosition() }.map { it.type }
if (filteredUpperConstraints.isNotEmpty()) intersectTypes(filteredUpperConstraints) else intersectionUpperType
} else intersectionUpperType
return typeApproximator.approximateToSubType(