Fix for issue 140; a mapped object element may have been cached in the
context under a more generic type.
Fix for issue 160; when a generic type from the argument is not
compatible with a type from the reference, favor the argument.