Stop extra function generation, fix #12581

Handle AnnotationRef case for Shape and Lightsource.