PY-25989 PY-84544 Widen types during type parameters substitution

(cherry picked from commit 627673fc7ed27621df839a5c1d4d31e677ce7f8c)

GitOrigin-RevId: 07803c6243370d55df0d870e2e32b38170c1fb49
This commit is contained in:
Petr
2025-11-26 18:52:04 +00:00
committed by intellij-monorepo-bot
parent a1e73e339b
commit 241ba26253
4 changed files with 81 additions and 21 deletions
@@ -40,7 +40,11 @@ def test():
print(result)
print(result + <warning descr="Expected type 'int', got 'str' instead">'foo'</warning>)
f2(1, <warning descr="Expected type 'List[int]' (matched generic type 'List[T]'), got 'List[str]' instead">['foo']</warning>, 'bar')
# Bug: Expected error.
# Generics are considered to be covariant.
# I.e. `list[str]` is assignable to `list[int | str]`.
# Thus, substitution `T` -> `int | str` is considered valid.
f2(1, ['foo'], 'bar')
result = f3(1, 'foo', True)
f4(<warning descr="Expected type 'Tuple[bool, int, str]', got 'Tuple[int, str, bool]' instead">result</warning>)