Skip to content

Static return type and if statements don't work together? #5029

@jenshaase

Description

@jenshaase

Hi,

I have a generic abstract class with a method foo that should return static<T>. It works as long there is be no if statement in the method. If I add a if statement to call the constructor with different parameters it will give me an error.

INFO: MoreSpecificReturnType - 21:17 - The declared return type 'A<T:A as mixed>' for A::foo 
is more specific than the inferred return type 'A<T:A as mixed>'

Here is a snippet:
https://psalm.dev/r/50b704a810

Is this a bug or did I miss something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions