summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inference.py7
-rw-r--r--infutils.py20
2 files changed, 19 insertions, 8 deletions
diff --git a/inference.py b/inference.py
index 1bd424b7..e0b216be 100644
--- a/inference.py
+++ b/inference.py
@@ -181,15 +181,16 @@ nodes.AssName.infer_lhs = infer_name # won't work with a path wrapper
def infer_callfunc(self, context=None):
"""infer a CallFunc node by trying to guess what the function returns"""
- context = context.clone()
- context.callcontext = CallContext(self.args, self.starargs, self.kwargs)
+ callcontext = context.clone()
+ callcontext.callcontext = CallContext(self.args, self.starargs, self.kwargs)
+ callcontext.boundnode = None
for callee in self.func.infer(context):
if callee is YES:
yield callee
continue
try:
if hasattr(callee, 'infer_call_result'):
- for infered in callee.infer_call_result(self, context):
+ for infered in callee.infer_call_result(self, callcontext):
yield infered
except InferenceError:
## XXX log error ?
diff --git a/infutils.py b/infutils.py
index 38d32a71..c74fbd54 100644
--- a/infutils.py
+++ b/infutils.py
@@ -222,12 +222,8 @@ class Instance(Proxy):
if '__builtin__.property' in attr.decoratornames():
for infered in attr.infer_call_result(self, context):
yield infered
- elif attr.type in ('method', 'classmethod'):
- # XXX could get some information from the bound node:
- # self (if method) or self._proxied (if class method)
- yield BoundMethod(attr)
else:
- yield attr
+ yield BoundMethod(attr, self)
else:
yield attr
@@ -259,6 +255,9 @@ class Instance(Proxy):
def pytype(self):
return self._proxied.qname()
+ def display_type(self):
+ return 'Instance of'
+
class UnboundMethod(Proxy):
"""a special node representing a method not bound to an instance"""
@@ -284,9 +283,18 @@ class UnboundMethod(Proxy):
class BoundMethod(UnboundMethod):
"""a special node representing a method bound to an instance"""
+ def __init__(self, proxy, bound):
+ UnboundMethod.__init__(self, proxy)
+ self.bound = bound
+
def is_bound(self):
return True
+ def infer_call_result(self, caller, context):
+ context = context.clone()
+ context.boundnode = self.bound
+ return self._proxied.infer_call_result(caller, context)
+
class Generator(Proxy):
"""a special node representing a generator"""
@@ -296,4 +304,6 @@ class Generator(Proxy):
def pytype(self):
return '__builtin__.generator'
+ def display_type(self):
+ return 'Generator'