Improve type safety in ProtobufList.concatenate

Use Collection<?> for the sizing check to eliminate unchecked cast warning and narrow @SuppressWarnings("unchecked") to the specific ProtobufList fast-path assignment.

PiperOrigin-RevId: 970165037
diff --git a/java/core/src/main/java/com/google/protobuf/Internal.java b/java/core/src/main/java/com/google/protobuf/Internal.java
index 51e7a08..14d6392 100644
--- a/java/core/src/main/java/com/google/protobuf/Internal.java
+++ b/java/core/src/main/java/com/google/protobuf/Internal.java
@@ -611,10 +611,10 @@
     ProtobufList<E> mutableCopyWithCapacity(int capacity);
 
     /** Appends the values to the end of the list. */
-    @SuppressWarnings("unchecked")
     static <E> ProtobufList<E> concatenate(ProtobufList<E> list, Iterable<? extends E> values) {
       // If the list is empty and the values are a ProtobufList, we may be able to avoid a copy.
       if (list.isEmpty() && values instanceof ProtobufList) {
+        @SuppressWarnings("unchecked")
         ProtobufList<E> other = (ProtobufList<E>) values;
         if (other.isEmpty()) {
           return list;
@@ -630,7 +630,7 @@
 
       // If values is a Collection, we can pre-size the list.
       if (values instanceof Collection) {
-        Collection<? extends E> other = (Collection<? extends E>) values;
+        Collection<?> other = (Collection<?>) values;
 
         if (!list.isModifiable()) {
           list = list.mutableCopyWithCapacity(list.size() + other.size());