diff --git a/lark/visitors.py b/lark/visitors.py index 7cd108a..c9f0e2d 100644 --- a/lark/visitors.py +++ b/lark/visitors.py @@ -24,11 +24,11 @@ class _Decoratable: # Make sure the function isn't inherited (unless it's overwritten) if name.startswith('_') or (name in libmembers and name not in cls.__dict__): continue - if not callable(cls.__dict__[name]): + if not callable(value): continue # Skip if v_args already applied (at the function level) - if hasattr(cls.__dict__[name], 'vargs_applied'): + if hasattr(cls.__dict__[name], 'vargs_applied') or hasattr(value, 'vargs_applied'): continue static = isinstance(cls.__dict__[name], (staticmethod, classmethod)) diff --git a/tests/test_trees.py b/tests/test_trees.py index edd2a8b..d759cf1 100644 --- a/tests/test_trees.py +++ b/tests/test_trees.py @@ -166,6 +166,15 @@ class TestTrees(TestCase): x = MyTransformer().transform( Tree('hello', [2])) self.assertEqual(x, 'hello') + def test_inline_static(self): + @v_args(inline=True) + class T(Transformer): + @staticmethod + def test(a, b): + return a + b + x = T().transform(Tree('test', ['a', 'b'])) + self.assertEqual(x, 'ab') + def test_vargs_override(self): t = Tree('add', [Tree('sub', [Tree('i', ['3']), Tree('f', ['1.1'])]), Tree('i', ['1'])])