[cs] Consider the inferred type rather than the type passed to Lib.as. Closes #3403