Add const type inference

This commit is contained in:
Ville Penttinen
2019-02-25 09:27:47 +02:00
parent 7ffff9c74c
commit 18b0bd9bff
11 changed files with 168 additions and 20 deletions

View File

@@ -0,0 +1,26 @@
use std::sync::Arc;
use ra_syntax::ast::{NameOwner};
use crate::{
Name, AsName, Const, ConstSignature,
type_ref::{TypeRef},
PersistentHirDatabase,
};
impl ConstSignature {
pub(crate) fn const_signature_query(
db: &impl PersistentHirDatabase,
konst: Const,
) -> Arc<ConstSignature> {
let (_, node) = konst.source(db);
let name = node.name().map(|n| n.as_name()).unwrap_or_else(Name::missing);
let type_ref = TypeRef::from_ast_opt(node.type_ref());
let sig = ConstSignature { name, type_ref };
Arc::new(sig)
}
}