Skip to content

Commit cc071c3

Browse files
committed
Handle void and never in is_self_like_type union filtering
1 parent 2693b66 commit cc071c3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/completion/call_resolution.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ fn is_self_like_type(ty: &PhpType) -> bool {
114114
PhpType::Generic(n, _) => is_self_keyword(n),
115115
PhpType::Nullable(inner) => is_self_like_type(inner),
116116
PhpType::Union(members) => {
117-
// `static|null` — every non-null member is self-like.
118-
let non_null: Vec<_> = members
117+
// `static|null`, `$this|void` — filter out non-class types
118+
// that cannot produce a class resolution, then check that
119+
// every remaining member is self-like.
120+
let significant: Vec<_> = members
119121
.iter()
120-
.filter(|m| !matches!(m, PhpType::Named(n) if n == "null"))
122+
.filter(|m| !matches!(m, PhpType::Named(n) if n == "null" || n == "void" || n == "never"))
121123
.collect();
122-
!non_null.is_empty() && non_null.iter().all(|m| is_self_like_type(m))
124+
!significant.is_empty() && significant.iter().all(|m| is_self_like_type(m))
123125
}
124126
_ => false,
125127
}

0 commit comments

Comments
 (0)