Add cycle recovery for type aliases
This commit is contained in:
parent
3ca40f7c08
commit
1c622e9fed
@ -22,6 +22,7 @@ pub trait HirDatabase: DefDatabase {
|
||||
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
|
||||
|
||||
#[salsa::invoke(crate::lower::ty_query)]
|
||||
#[salsa::cycle(crate::lower::ty_recover)]
|
||||
fn ty(&self, def: TyDefId) -> Ty;
|
||||
|
||||
#[salsa::invoke(crate::lower::value_ty_query)]
|
||||
|
@ -742,6 +742,11 @@ pub(crate) fn ty_query(db: &impl HirDatabase, def: TyDefId) -> Ty {
|
||||
TyDefId::TypeAliasId(it) => type_for_type_alias(db, it),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn ty_recover(_db: &impl HirDatabase, _cycle: &[String], _def: &TyDefId) -> Ty {
|
||||
Ty::Unknown
|
||||
}
|
||||
|
||||
pub(crate) fn value_ty_query(db: &impl HirDatabase, def: ValueTyDefId) -> Ty {
|
||||
match def {
|
||||
ValueTyDefId::FunctionId(it) => type_for_fn(db, it),
|
||||
|
@ -2154,7 +2154,6 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic] // we currently can't handle this
|
||||
fn recursive_type_alias() {
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
@ -2163,7 +2162,10 @@ type Foo = Foo;
|
||||
type Bar = A<Bar>;
|
||||
fn test(x: Foo) {}
|
||||
"#),
|
||||
@""
|
||||
@r###"
|
||||
[59; 60) 'x': {unknown}
|
||||
[67; 69) '{}': ()
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user