From 88c529ee5977737af61f61a2efb3442cc2bcf9c5 Mon Sep 17 00:00:00 2001 From: Clayton Knittel Date: Wed, 17 Jun 2026 12:12:14 -0700 Subject: [PATCH] Replace builtin casts with proto-specific casts for protobuf types. There is a protobuf experiment to "devirtualize" messages, allowing protobuf to manage the dynamic dispatch of messages. When enabled, it breaks builtin dynamic/down casts, so the protobuf-specific alternatives should be preferred. PiperOrigin-RevId: 933855646 --- cc/google/fhir/profiles_lib.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cc/google/fhir/profiles_lib.h b/cc/google/fhir/profiles_lib.h index 538f377a7f..d4b9f73c4b 100644 --- a/cc/google/fhir/profiles_lib.h +++ b/cc/google/fhir/profiles_lib.h @@ -79,9 +79,10 @@ absl::Status PerformExtensionSlicing( for (int i = 0; i < source.GetReflection()->FieldSize(source, source_extension_field); ++i) { - const ExtensionLike& source_extension = dynamic_cast( - source_reflection->GetRepeatedMessage(source, source_extension_field, - i)); + const ExtensionLike& source_extension = + google::protobuf::DynamicCastMessage( + source_reflection->GetRepeatedMessage(source, + source_extension_field, i)); ScopedErrorReporter scope = error_reporter.WithScope("extensions", i); const std::string& url = source_extension.url().value(); const auto extension_entry_iter = extension_map.find(url);