Calling an InstanceElement of an Instance of CompiledObject doesn't raise an error anymore. Yes, it's really that complicated.

This commit is contained in:
Dave Halter
2014-07-30 19:49:41 +02:00
parent 0851e7667e
commit 870abe73d4
3 changed files with 21 additions and 4 deletions

View File

@@ -78,7 +78,7 @@ def search_params(evaluator, param):
pos = c.start_pos pos = c.start_pos
scope = stmt.parent scope = stmt.parent
# this whole stuff is just to not execute certain parts # This whole stuff is just to not execute certain parts
# (speed improvement), basically we could just call # (speed improvement), basically we could just call
# ``eval_call_path`` on the call_path and it would # ``eval_call_path`` on the call_path and it would
# also work. # also work.

View File

@@ -58,7 +58,7 @@ class Instance(use_metaclass(CachedMetaClass, Executed)):
# compare the module path with the builtin name. # compare the module path with the builtin name.
self.var_args = iterable.check_array_instances(evaluator, self) self.var_args = iterable.check_array_instances(evaluator, self)
else: else:
# need to execute the __init__ function, because the dynamic param # Need to execute the __init__ function, because the dynamic param
# searching needs it. # searching needs it.
with common.ignored(KeyError): with common.ignored(KeyError):
self.execute_subscope_by_name('__init__', self.var_args) self.execute_subscope_by_name('__init__', self.var_args)
@@ -251,9 +251,14 @@ class InstanceElement(use_metaclass(CachedMetaClass, pr.Base)):
return isinstance(self.var, cls) return isinstance(self.var, cls)
def py__call__(self, evaluator, params): def py__call__(self, evaluator, params):
# TODO Why are CompiledObject and Instance even InstanceObjects? # TODO Why is CompiledObject even an InstanceObject?
if isinstance(self.var, (compiled.CompiledObject, Instance)): if isinstance(self.var, (compiled.CompiledObject, Instance)):
return self.var.py__call__(evaluator, params) try:
func = self.var.py__call__
except AttributeError:
return []
else:
return func(evaluator, params)
else: else:
return Function.py__call__(self, evaluator, params) return Function.py__call__(self, evaluator, params)

View File

@@ -191,6 +191,18 @@ f()
#? int() #? int()
g() g()
class X():
@str
def x(self):
pass
def y(self):
#? str()
self.x
#?
self.x()
# ----------------- # -----------------
# method decorators # method decorators
# ----------------- # -----------------