Skip to content

Commit 314295c

Browse files
stroxlerfacebook-github-bot
authored andcommitted
reveal_type should work with type_info
Summary: All we need is to use our existing display, but also make sure that the `expand` and `for_display` transforms are applied throughout the `TypeInfo`. Reviewed By: ndmitchell Differential Revision: D72496978 fbshipit-source-id: 4160edbc779b74c3c7f9e5c943d56e3d9ccfdaba
1 parent 8f0127b commit 314295c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyrefly/lib/alt/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
596596
self.expr_infer_type_info(x, errors).into_ty()
597597
}
598598

599-
fn expr_infer_type_info(&self, x: &Expr, errors: &ErrorCollector) -> TypeInfo {
599+
pub fn expr_infer_type_info(&self, x: &Expr, errors: &ErrorCollector) -> TypeInfo {
600600
self.expr_infer_type_info_with_hint(x, None, errors)
601601
}
602602

pyrefly/lib/alt/special_calls.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use crate::error::kind::ErrorKind;
2424
use crate::types::callable::unexpected_keyword;
2525
use crate::types::special_form::SpecialForm;
2626
use crate::types::types::Type;
27+
use crate::util::visit::VisitMut;
2728

2829
impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
2930
pub fn call_assert_type(
@@ -97,13 +98,16 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
9798
errors: &ErrorCollector,
9899
) -> Type {
99100
if args.len() == 1 {
100-
let t = self.solver().deep_force(self.expr_infer(&args[0], errors));
101+
let mut type_info = self.expr_infer_type_info(&args[0], errors);
102+
type_info.visit_mut(&mut |ty| {
103+
*ty = self.for_display(self.solver().deep_force(ty.clone()));
104+
});
101105
self.error(
102106
errors,
103107
range,
104108
ErrorKind::RevealType,
105109
None,
106-
format!("revealed type: {}", self.for_display(t)),
110+
format!("revealed type: {}", type_info),
107111
);
108112
} else {
109113
self.error(

0 commit comments

Comments
 (0)