[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>
This commit is contained in:
Nicholas Shahan 2022-07-01 18:29:10 +00:00 committed by Commit Bot
parent bc458d5341
commit f3daca2ef6

View file

@ -6534,7 +6534,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
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;
}