Skip to content

Commit 3fff5aa

Browse files
committed
Use Ty::apply instead of simple and fix method resolution.
1 parent eb96964 commit 3fff5aa

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

crates/hir_ty/src/lower.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,13 +1102,13 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
11021102
let ctx =
11031103
TyLoweringContext::new(db, &resolver).with_type_param_mode(TypeParamLoweringMode::Variable);
11041104
let substs = Substs::bound_vars(&generics, DebruijnIndex::INNERMOST);
1105-
let inner = if db.type_alias_data(t).is_extern {
1106-
Ty::simple(TypeCtor::ForeignType(t))
1105+
if db.type_alias_data(t).is_extern {
1106+
Binders::new(substs.len(), Ty::apply(TypeCtor::ForeignType(t), substs))
11071107
} else {
11081108
let type_ref = &db.type_alias_data(t).type_ref;
1109-
Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error))
1110-
};
1111-
Binders::new(substs.len(), inner)
1109+
let inner = Ty::from_hir(&ctx, type_ref.as_ref().unwrap_or(&TypeRef::Error));
1110+
Binders::new(substs.len(), inner)
1111+
}
11121112
}
11131113

11141114
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

crates/hir_ty/src/method_resolution.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ impl Ty {
250250
TypeCtor::Adt(def_id) => {
251251
return Some(std::iter::once(def_id.module(db.upcast()).krate).collect())
252252
}
253+
TypeCtor::ForeignType(type_alias_id) => {
254+
return Some(
255+
std::iter::once(
256+
type_alias_id.lookup(db.upcast()).module(db.upcast()).krate,
257+
)
258+
.collect(),
259+
)
260+
}
253261
TypeCtor::Bool => lang_item_crate!("bool"),
254262
TypeCtor::Char => lang_item_crate!("char"),
255263
TypeCtor::Float(f) => match f.bitness {

crates/hir_ty/src/tests/method_resolution.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,6 @@ fn method_resolution_foreign_opaque_type() {
10721072
s.foo();
10731073
}
10741074
"#,
1075-
// FIXME: 's.foo()' should be `bool`.
10761075
expect![[r#"
10771076
75..79 'self': &S
10781077
89..109 '{ ... }': bool
@@ -1084,8 +1083,7 @@ fn method_resolution_foreign_opaque_type() {
10841083
146..147 'f': fn f() -> &S
10851084
146..149 'f()': &S
10861085
157..158 's': &S
1087-
157..164 's.foo()': {unknown}
1086+
157..164 's.foo()': bool
10881087
"#]],
10891088
);
10901089
}
1091-

0 commit comments

Comments
 (0)