Stop extra function generation, see #12581

Handle AnnotationRef case for Shape and Lightsource.