You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to to add some conversion utility methods to a generic Collection class, such as asObjects() returning a more specific collection type.
I've tried to use @psalm-if-this-is self<object> to prevent asObjects() from being called on an incompatible collection type, but I've ran into issues when the template is invariant:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello.
I'm trying to to add some conversion utility methods to a generic
Collection
class, such asasObjects()
returning a more specific collection type.I've tried to use
@psalm-if-this-is self<object>
to preventasObjects()
from being called on an incompatible collection type, but I've ran into issues when the template is invariant:https://psalm.dev/r/485bd7707a
The
InvalidTemplateParam
could be ignored, but I'm also gettingIfThisIsMismatch
on the call site which is a problem.Since
@psalm-if-this-is
doesn't change the type of$this
after the call, shouldn't it be able to assert any type regardless of variance?Beta Was this translation helpful? Give feedback.
All reactions