File tree 1 file changed +17
-1
lines changed
crates/red_knot_python_semantic/src/types 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -317,7 +317,7 @@ impl<'db> InnerIntersectionBuilder<'db> {
317
317
// Adding any of these types to the negative side of an intersection
318
318
// is equivalent to adding it to the positive side. We do this to
319
319
// simplify the representation.
320
- self.positive.insert( ty);
320
+ self.add_positive(db, ty);
321
321
}
322
322
// ~Literal[True] & bool = Literal[False]
323
323
Type::BooleanLiteral(bool)
@@ -592,6 +592,22 @@ mod tests {
592
592
assert_eq!(ta_not_i0.display(&db).to_string(), "int & Any | Literal[1]");
593
593
}
594
594
595
+ #[test]
596
+ fn build_intersection_simplify_negative_any() {
597
+ let db = setup_db();
598
+
599
+ let ty = IntersectionBuilder::new(&db)
600
+ .add_negative(Type::Any)
601
+ .build();
602
+ assert_eq!(ty, Type::Any);
603
+
604
+ let ty = IntersectionBuilder::new(&db)
605
+ .add_positive(Type::Never)
606
+ .add_negative(Type::Any)
607
+ .build();
608
+ assert_eq!(ty, Type::Never);
609
+ }
610
+
595
611
#[test]
596
612
fn intersection_distributes_over_union() {
597
613
let db = setup_db();
You can’t perform that action at this time.
0 commit comments