bestViableReferenceCandidate
This function returns the best viable declaration when resolving a Reference. The candidates to chose from are stored in Reference.candidates In most cases the languages can keep the default implementation, which only returns a declaration, if the list contains one single item. Otherwise, we have an ambiguous result and cannot determine the result with certainty.
If we encounter an ambiguous result, a warning is issued.