Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ed34978

Browse files
committed
Add public function for resolving ast::Expr to hir::Callable
1 parent 0ac05c0 commit ed34978

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/hir/src/semantics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,10 @@ impl<'db> SemanticsImpl<'db> {
11201120
self.analyze(pat.syntax())?.binding_mode_of_pat(self.db, pat)
11211121
}
11221122

1123+
pub fn resolve_expr_as_callable(&self, call: &ast::Expr) -> Option<Callable> {
1124+
self.analyze(call.syntax())?.resolve_expr_as_callable(self.db, call)
1125+
}
1126+
11231127
pub fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<Function> {
11241128
self.analyze(call.syntax())?.resolve_method_call(self.db, call)
11251129
}

crates/hir/src/source_analyzer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ impl SourceAnalyzer {
303303
}
304304
}
305305

306+
pub(crate) fn resolve_expr_as_callable(
307+
&self,
308+
db: &dyn HirDatabase,
309+
call: &ast::Expr,
310+
) -> Option<Callable> {
311+
self.type_of_expr(db, &call.clone())?.0.as_callable(db)
312+
}
313+
306314
pub(crate) fn resolve_field(
307315
&self,
308316
db: &dyn HirDatabase,

0 commit comments

Comments
 (0)