mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-24 02:14:17 +00:00
objc: fix _classmethods_ dispatch flag (#14854)
* objc: fix _classmethods_ dispatch flag * test: add objc _classmethods_ regression
This commit is contained in:
parent
f551a4bded
commit
a1696e8413
2 changed files with 18 additions and 1 deletions
17
test/unit/test_objc.py
Normal file
17
test/unit/test_objc.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import sys, unittest
|
||||
|
||||
class TestObjCMetaSpec(unittest.TestCase):
|
||||
@unittest.skipUnless(sys.platform == "darwin", "objc runtime only on macOS")
|
||||
def test_classmethods_are_classmethods(self):
|
||||
from tinygrad.runtime.support.objc import Spec, id_
|
||||
|
||||
#_classmethods_ must include classmethod descriptors
|
||||
class ObjCTest(Spec):
|
||||
_methods_ = [("foo", id_, [])]
|
||||
_classmethods_ = [("bar", id_, [])]
|
||||
|
||||
self.assertNotIsInstance(ObjCTest.__dict__["foo"], classmethod)
|
||||
self.assertIsInstance(ObjCTest.__dict__["bar"], classmethod)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -49,7 +49,7 @@ else:
|
|||
def __setattr__(cls, k, v):
|
||||
super().__setattr__(k, v)
|
||||
if k in ("_methods_", "_classmethods_"):
|
||||
for m in v: cls._addmeth(m, clsmeth=(v=="_classmethods_"))
|
||||
for m in v: cls._addmeth(m, clsmeth=(k=="_classmethods_"))
|
||||
for c in cls._children_: c._inherit(cls)
|
||||
if k == "_bases_":
|
||||
for b in v:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue