Type resolution
. Try all possible types of each overloaded function (possible but brute force method!)
. Keep track of all possible types
. Discard invalid possibilities
. At the end, check if there is a single unique type
. Overloading can be resolved in two passes:
- Bottom up: compute set of all possible types for each expression
- Top down: narrow set of possible types based on what could be used in an expression
Now the question arises : how should the type be resolved? One possible brute force method is to try all possible types of each overloaded function. A better way to do this is to keep a track of all possible types and discard invalid possibilities. At the end if the compiler finds one unique type left then the ambiguity is resolved.
Overloading can be resolved in two passes which are described above. You will have a look at them in the next slide.
|