Fix #25720: nil element matches model in anyOf

IN
19h ago
+48-3

Fixes #25720

Polymorphism.cast_raw (the anyOf/oneOf resolution runtime) treated a nil array/hash element asymmetrically: a model candidate accepted it (returned nil), a primitive candidate returned NO_MATCH — so cast('Array<Integer>', [1, nil]) failed the whole resolution with nil, while cast('Array<Pet>', [pet, nil]) returned [Pet, nil]. This contradicted the sentinel's own doc that a nullable element is a legitimate match.

cast_raw now returns nil uniformly for data.nil? at the top (null matches every candidate), and the model-specific data.nil? ? nil : special case in the else branch is removed. Both committed generated runtimes (petstore, ruby-nextgen-qdrant) carry the identical 2-hunk change.

5-case rspec fixture: nil elements kept for Array<Integer/String/Boolean> and Hash<String, Integer>, model candidates against a real validating Pet, rejection guards (wrong-type element, invalid model element, non-array), nil top-level data on every candidate type. Verified pre-fix reproduction (exact issue output) and post-fix match ([1, nil] / [Pet, NilClass]); full petstore rspec suite green (28 examples).


Summary by cubic

Fixes #25720 by making Polymorphism.cast_raw treat nil data as a legitimate match for every candidate type, so a nil element in an Array<Integer> or Hash<String, Integer> no longer causes the whole anyOf/oneOf resolution to fail. Previously primitive candidates rejected nil while model candidates accepted it, leading to inconsistent results like [1, nil] failing but [Pet, nil] succeeding. The change adds a single early return for data.nil? and removes the model-specific special case.

Samples for petstore and ruby-nextgen-qdrant are regenerated from the same two-hunk template change, and a new spec covers nil elements for primitive and model candidates plus rejection guards.