diff --git a/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md b/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md index 4379498f2d..1d7cbfd401 100644 --- a/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md +++ b/crates/ty_python_semantic/resources/mdtest/exhaustiveness_checking.md @@ -284,10 +284,17 @@ python-version = "3.12" ```py from typing import assert_never -class A[T]: ... +class A[T]: + value: T + class ASub[T](A[T]): ... -class B[T]: ... -class C[T]: ... + +class B[T]: + value: T + +class C[T]: + value: T + class D: ... class E: ... class F: ... diff --git a/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs b/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs index d7ab0f621c..76ec1a70f0 100644 --- a/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs +++ b/crates/ty_python_semantic/src/semantic_index/reachability_constraints.rs @@ -336,6 +336,7 @@ fn pattern_kind_to_type<'db>(db: &'db dyn Db, kind: &PatternPredicateKind<'db>) infer_expression_type(db, *class_expr, TypeContext::default()) .to_instance(db) .unwrap_or(Type::Never) + .top_materialization(db) } else { Type::Never }