Skip to content

Commit ae6fde1

Browse files
authored
[red-knot] Move InstanceType to its own submodule (#17525)
1 parent d2b20f7 commit ae6fde1

File tree

8 files changed

+577
-528
lines changed

8 files changed

+577
-528
lines changed

crates/red_knot_python_semantic/src/types.rs

Lines changed: 94 additions & 114 deletions
Large diffs are not rendered by default.

crates/red_knot_python_semantic/src/types/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<'db> InnerIntersectionBuilder<'db> {
493493
_ => {
494494
let known_instance = new_positive
495495
.into_instance()
496-
.and_then(|instance| instance.class.known(db));
496+
.and_then(|instance| instance.class().known(db));
497497

498498
if known_instance == Some(KnownClass::Object) {
499499
// `object & T` -> `T`; it is always redundant to add `object` to an intersection
@@ -513,7 +513,7 @@ impl<'db> InnerIntersectionBuilder<'db> {
513513
new_positive = Type::BooleanLiteral(false);
514514
}
515515
Type::Instance(instance)
516-
if instance.class.is_known(db, KnownClass::Bool) =>
516+
if instance.class().is_known(db, KnownClass::Bool) =>
517517
{
518518
match new_positive {
519519
// `bool & AlwaysTruthy` -> `Literal[True]`
@@ -607,7 +607,7 @@ impl<'db> InnerIntersectionBuilder<'db> {
607607
self.positive
608608
.iter()
609609
.filter_map(|ty| ty.into_instance())
610-
.filter_map(|instance| instance.class.known(db))
610+
.filter_map(|instance| instance.class().known(db))
611611
.any(KnownClass::is_bool)
612612
};
613613

@@ -623,7 +623,7 @@ impl<'db> InnerIntersectionBuilder<'db> {
623623
Type::Never => {
624624
// Adding ~Never to an intersection is a no-op.
625625
}
626-
Type::Instance(instance) if instance.class.is_object(db) => {
626+
Type::Instance(instance) if instance.class().is_object(db) => {
627627
// Adding ~object to an intersection results in Never.
628628
*self = Self::default();
629629
self.positive.insert(Type::Never);

0 commit comments

Comments
 (0)