Allow Pattern.ref() to take an Abstract

This commit is contained in:
jan 2023-10-12 01:31:05 -07:00
parent c53057e5f6
commit 9d5177ce63

View File

@ -681,7 +681,7 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
""" """
return bool(self.ports) return bool(self.ports)
def ref(self, target: str | None, *args: Any, **kwargs: Any) -> Self: def ref(self, target: str | Abstract | None, *args: Any, **kwargs: Any) -> Self:
""" """
Convenience function which constructs a `Ref` object and adds it Convenience function which constructs a `Ref` object and adds it
to this pattern. to this pattern.
@ -694,6 +694,8 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
Returns: Returns:
self self
""" """
if isinstance(target, Abstract):
target = target.name
self.refs[target].append(Ref(*args, **kwargs)) self.refs[target].append(Ref(*args, **kwargs))
return self return self