KT-4976 Completion ignores smart casts

 #KT-4976 Fixed
 #KT-5718 Fixed
Moved too specific function out of ExpressionTypingUtils (and refactored it)