Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pyrefly/lib/alt/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,19 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
.heap
.mk_class_type(self.stdlib.list(elem.to_type(self.heap)));
if self.is_subset_eq(&list_type, hint) {
self.resolve_var_opt(hint, elem)
let elem = self.resolve_var_opt(hint, elem);
// A bounded call type variable may only decompose to the `Any` in its bound. In that
// case the unhinted list type provides the useful constraint for solving the call.
if elem.as_ref().is_some_and(Type::is_any)
&& hint
.collect_maybe_placeholder_vars()
.into_iter()
.any(|var| self.solver().var_is_quantified(var))
{
None
} else {
elem
}
} else {
None
}
Expand Down
9 changes: 9 additions & 0 deletions pyrefly/lib/test/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ reduce(max, [1,2])
"#,
);

testcase!(
test_iter_list_literal,
r#"
from typing import Iterator, assert_type

assert_type(iter([0]), Iterator[int])
"#,
);

testcase!(
test_call_arg_lambda_contextual_typing,
r#"
Expand Down
Loading