1.1 --- a/micropython/deduce.py Wed Oct 23 18:15:41 2013 +0200
1.2 +++ b/micropython/deduce.py Wed Oct 23 18:18:30 2013 +0200
1.3 @@ -92,9 +92,12 @@
1.4
1.5 unit = self.get_unit()
1.6
1.7 - # Remember to permit deductions on the expression node.
1.8 + # Remember to permit deductions on the expression node. Here, we may
1.9 + # also obtain a concrete type associated with an instantiation.
1.10
1.11 - self.dispatch(node.expr)
1.12 + expr_type = self.dispatch(node.expr)
1.13 + if not node._expr or isinstance(node._expr, Instance):
1.14 + node._expr = expr_type
1.15
1.16 # The target, on which the access is performed, may influence the effect
1.17 # on the context. We can only reliably assume that a literal constant is
1.18 @@ -284,6 +287,22 @@
1.19
1.20 visitAssAttr = visitGetattr = _visitAttr
1.21
1.22 + def visitCallFunc(self, node):
1.23 +
1.24 + "Identify any concrete types involved with instantiation."
1.25 +
1.26 + for n in node.getChildNodes():
1.27 + self.dispatch(n)
1.28 +
1.29 + # Determine whether the target of the invocation refers to a class.
1.30 +
1.31 + attr = node.node._attr
1.32 +
1.33 + if attr:
1.34 + value = attr.get_value()
1.35 + if value and isinstance(value, Class):
1.36 + return attr
1.37 +
1.38 # Convenience functions.
1.39
1.40 def deduce(program):