From 444f799f5e86d79bf3cf9c5a567ae7e82fa629a9 Mon Sep 17 00:00:00 2001 From: InSync Date: Sun, 19 Jan 2025 23:37:22 +0700 Subject: [PATCH] [red-knot] Two gradual equivalent fully static types are also equivalent (#15579) --- .../src/types/property_tests.rs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/red_knot_python_semantic/src/types/property_tests.rs b/crates/red_knot_python_semantic/src/types/property_tests.rs index cd434e99b716f9..2479e6457bc640 100644 --- a/crates/red_knot_python_semantic/src/types/property_tests.rs +++ b/crates/red_knot_python_semantic/src/types/property_tests.rs @@ -351,6 +351,20 @@ mod stable { s.is_fully_static(db) && t.is_fully_static(db) => s.is_subtype_of(db, union(db, [s, t])) && t.is_subtype_of(db, union(db, [s, t])) ); + + // A fully static type does not have any materializations. + // Thus, two equivalent (fully static) types are also gradual equivalent. + type_property_test!( + two_equivalent_types_are_also_gradual_equivalent, db, + forall types s, t. s.is_equivalent_to(db, t) => s.is_gradual_equivalent_to(db, t) + ); + + // Two gradual equivalent fully static types are also equivalent. + type_property_test!( + two_gradual_equivalent_fully_static_types_are_also_equivalent, db, + forall types s, t. + s.is_fully_static(db) && s.is_gradual_equivalent_to(db, t) => s.is_equivalent_to(db, t) + ); } /// This module contains property tests that currently lead to many false positives. @@ -440,11 +454,4 @@ mod flaky { .permutations(2) .all(|vec_of_unions| vec_of_unions[0].is_equivalent_to(db, vec_of_unions[1])) ); - - // A fully static type does not have any materializations. - // Thus, two equivalent (fully static) types are also gradual equivalent. - type_property_test!( - two_equivalent_types_are_also_gradual_equivalent, db, - forall types s, t. s.is_equivalent_to(db, t) => s.is_gradual_equivalent_to(db, t) - ); }