diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index 404ed996f34..10866514d52 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -671,8 +671,12 @@ private static function expandNamedObject( $return_type->is_static = true; } } elseif ($return_type->is_static - && ($static_class_type instanceof TNamedObject - || $static_class_type instanceof TTemplateParam) + && (($static_class_type instanceof TNamedObject + && $codebase->classlikes->classExtends( + $static_class_type->value, + $return_type->value + ) + ) || $static_class_type instanceof TTemplateParam) ) { $return_type_types = $return_type->getIntersectionTypes(); $cloned_static = $static_class_type->setIntersectionTypes([]);