mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
fix: Type::{And, Or}(Set<Type>)
This commit is contained in:
parent
82bc710827
commit
b0c31370c5
14 changed files with 661 additions and 466 deletions
|
@ -42,24 +42,30 @@ fn comp_item_kind(t: &Type, muty: Mutability) -> CompletionItemKind {
|
|||
Type::Subr(_) | Type::Quantified(_) => CompletionItemKind::FUNCTION,
|
||||
Type::ClassType => CompletionItemKind::CLASS,
|
||||
Type::TraitType => CompletionItemKind::INTERFACE,
|
||||
Type::Or(l, r) => {
|
||||
let l = comp_item_kind(l, muty);
|
||||
let r = comp_item_kind(r, muty);
|
||||
if l == r {
|
||||
l
|
||||
Type::Or(tys) => {
|
||||
let fst = comp_item_kind(tys.iter().next().unwrap(), muty);
|
||||
if tys
|
||||
.iter()
|
||||
.map(|t| comp_item_kind(t, muty))
|
||||
.all(|k| k == fst)
|
||||
{
|
||||
fst
|
||||
} else if muty.is_const() {
|
||||
CompletionItemKind::CONSTANT
|
||||
} else {
|
||||
CompletionItemKind::VARIABLE
|
||||
}
|
||||
}
|
||||
Type::And(l, r) => {
|
||||
let l = comp_item_kind(l, muty);
|
||||
let r = comp_item_kind(r, muty);
|
||||
if l == CompletionItemKind::VARIABLE {
|
||||
r
|
||||
Type::And(tys) => {
|
||||
for k in tys.iter().map(|t| comp_item_kind(t, muty)) {
|
||||
if k != CompletionItemKind::VARIABLE {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
if muty.is_const() {
|
||||
CompletionItemKind::CONSTANT
|
||||
} else {
|
||||
l
|
||||
CompletionItemKind::VARIABLE
|
||||
}
|
||||
}
|
||||
Type::Refinement(r) => comp_item_kind(&r.t, muty),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue