Only set object as context if it is from the right type