[ddc] Fix cast when retrieving annotation name

Name can be null and cast failures start appearing here when
running with sound null safety.

Issue: https://github.com/dart-lang/sdk/issues/46617
Change-Id: I3d96e80283889915cc28a310a1db940a9c6bcab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250409
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 3bc7339..04deb4c 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -6534,7 +6534,7 @@
   String? _annotationName(NamedNode node, bool Function(Expression) test) {
     var annotation = findAnnotation(node, test);
     return annotation != null
-        ? _constants.getFieldValueFromAnnotation(annotation, 'name') as String
+        ? _constants.getFieldValueFromAnnotation(annotation, 'name') as String?
         : null;
   }