Skip to content

Commit c9de103

Browse files
wanda-phiwhitequark
authored andcommitted
hdl: remove ValueCastable.lowermethod.
1 parent 61c5442 commit c9de103

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed

amaranth/hdl/_ast.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,20 +1472,6 @@ def shape(self, *args, **kwargs):
14721472
"""
14731473
return super().shape(*args, **kwargs) # :nocov:
14741474

1475-
# TODO(amaranth-0.6): remove
1476-
@staticmethod
1477-
@deprecated("`ValueCastable.lowermethod` is no longer required and will be removed in Amaranth 0.6")
1478-
def lowermethod(func):
1479-
@functools.wraps(func)
1480-
def wrapper_memoized(self, *args, **kwargs):
1481-
# Use `in self.__dict__` instead of `hasattr` to avoid interfering with custom
1482-
# `__getattr__` implementations.
1483-
if not "_ValueCastable__lowered_to" in self.__dict__:
1484-
self.__lowered_to = func(self, *args, **kwargs)
1485-
return self.__lowered_to
1486-
wrapper_memoized.__memoized = True
1487-
return wrapper_memoized
1488-
14891475

14901476
class _ValueLikeMeta(type):
14911477
def __subclasscheck__(cls, subclass):

tests/test_hdl_ast.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,30 +1483,15 @@ def as_value(self):
14831483
return self.dest
14841484

14851485

1486-
class MockValueCastableChanges(ValueCastable):
1487-
def __init__(self, width=0):
1488-
self.width = width
1489-
1490-
def shape(self):
1491-
return unsigned(self.width)
1492-
1493-
with _ignore_deprecated():
1494-
@ValueCastable.lowermethod
1495-
def as_value(self):
1496-
return Signal(self.width)
1497-
1498-
14991486
class MockValueCastableCustomGetattr(ValueCastable):
15001487
def __init__(self):
15011488
pass
15021489

15031490
def shape(self):
15041491
assert False
15051492

1506-
with _ignore_deprecated():
1507-
@ValueCastable.lowermethod
1508-
def as_value(self):
1509-
return Const(0)
1493+
def as_value(self):
1494+
return Const(0)
15101495

15111496
def __getattr__(self, attr):
15121497
assert False
@@ -1531,16 +1516,6 @@ def __init__(self):
15311516
def as_value(self):
15321517
return Signal()
15331518

1534-
def test_memoized(self):
1535-
vc = MockValueCastableChanges(1)
1536-
sig1 = vc.as_value()
1537-
vc.width = 2
1538-
sig2 = vc.as_value()
1539-
self.assertIs(sig1, sig2)
1540-
vc.width = 3
1541-
sig3 = Value.cast(vc)
1542-
self.assertIs(sig1, sig3)
1543-
15441519
def test_custom_getattr(self):
15451520
vc = MockValueCastableCustomGetattr()
15461521
vc.as_value() # shouldn't call __getattr__

0 commit comments

Comments
 (0)