fix crash when a custom class lookup method returns arbitrary non-type objects