mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-29 05:03:34 +08:00
parent
c585784cd9
commit
2f37b1d1c0
@ -561,7 +561,11 @@ class StitchingInferencer(Inferencer):
|
||||
# of having the host-to-ARTIQ mapping code in only one place and
|
||||
# also immediately getting proper diagnostics on type errors.
|
||||
attr_value = getattr(object_value, attr_name)
|
||||
if inspect.ismethod(attr_value) and types.is_instance(object_type):
|
||||
if (inspect.ismethod(attr_value) and
|
||||
types.is_instance(object_type) and
|
||||
# Check that the method is indeed defined on the class,
|
||||
# and not just this instance.
|
||||
hasattr(type(attr_value), attr_name)):
|
||||
# In cases like:
|
||||
# class c:
|
||||
# @kernel
|
||||
|
22
artiq/test/lit/embedding/method_on_instance.py
Normal file
22
artiq/test/lit/embedding/method_on_instance.py
Normal file
@ -0,0 +1,22 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.embedding %s
|
||||
|
||||
from artiq.language.core import *
|
||||
from artiq.language.types import *
|
||||
|
||||
class a:
|
||||
def foo(self, x):
|
||||
print(x)
|
||||
|
||||
class b:
|
||||
def __init__(self):
|
||||
self.obj = a()
|
||||
self.meth = self.obj.foo
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.meth(1)
|
||||
|
||||
bi = b()
|
||||
@kernel
|
||||
def entrypoint():
|
||||
bi.run()
|
Loading…
Reference in New Issue
Block a user