[ty] allow T: Never as subtype of Never (#18687)

This commit is contained in:
Felix Scherz 2025-06-16 19:46:17 +02:00 committed by GitHub
parent 5e57e4680f
commit 373a3bfcd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 6 deletions

View file

@ -1204,9 +1204,7 @@ impl<'db> Type<'db> {
// `Never` is the bottom type, the empty set.
// It is a subtype of all other fully static types.
// No other fully static type is a subtype of `Never`.
(Type::Never, _) => true,
(_, Type::Never) => false,
// Everything is a subtype of `object`.
(_, Type::NominalInstance(instance)) if instance.class.is_object(db) => true,
@ -1260,6 +1258,11 @@ impl<'db> Type<'db> {
true
}
// `Never` is the bottom type, the empty set.
// Other than one unlikely edge case (TypeVars bound to `Never`),
// no other fully static type is a subtype of `Never`.
(_, Type::Never) => false,
(Type::Union(union), _) => union
.elements(db)
.iter()