next up previous contents
Next: Modules Up: Types Previous: Type Annotations   Contents

Type Inference

Type-inference on syntax trees is driven by calling inferTypes on the Syntax Node in question. This will process type information already annotated to produce derived annotations on related nodes.

Also, there is a facility to extend the type-inference capability per method. To explain, each Type object comes with a rules object slot that is dual to the traits delegate object; rules delegate as the traits do but do not confer to the types their methods. Instead, they are used by the inference system transparently to allow for more intelligent specialization. To wit:

_@((Member of: {True. False}) rules) ifTrue: then@(Block rules) 
   ifFalse: else@(Block rules) 

  then returnType union: else returnType 
].
is a type-inference extension method for #ifTrue:ifFalse: for any boolean and a pair of blocks, that the return type will be in the union of the blocks' return types.



Brian Rice 2004-08-24