diff --git a/pkg/_fe_analyzer_shared/lib/src/macros/executor/serialization_extensions.dart b/pkg/_fe_analyzer_shared/lib/src/macros/executor/serialization_extensions.dart index c2fe1bc5c2c..43bd1239363 100644 --- a/pkg/_fe_analyzer_shared/lib/src/macros/executor/serialization_extensions.dart +++ b/pkg/_fe_analyzer_shared/lib/src/macros/executor/serialization_extensions.dart @@ -501,9 +501,11 @@ extension DeserializerExtensions on Deserializer { new DiagnosticMessage(message, target: target.asDiagnosticTarget), TypeAnnotationImpl() => new DiagnosticMessage(message, target: target.asDiagnosticTarget), + MetadataAnnotationImpl() => + new DiagnosticMessage(message, target: target.asDiagnosticTarget), _ => throw new UnsupportedError( - 'Unsupported target type ${target.runtimeType}, only Declarations ' - 'and TypeAnnotations are allowed.'), + 'Unsupported target type ${target.runtimeType}, only Declarations, ' + 'TypeAnnotations, and Metadata are allowed.'), }; } } diff --git a/tests/language/macros/json/json_serializable_diagnostics_test.dart b/tests/language/macros/json/json_serializable_diagnostics_test.dart index 2c3972a9f02..c00dd58e678 100644 --- a/tests/language/macros/json/json_serializable_diagnostics_test.dart +++ b/tests/language/macros/json/json_serializable_diagnostics_test.dart @@ -85,7 +85,7 @@ class EnumField { } @JsonSerializable() -class EnumField { +class DuplicateJsonKey { @JsonKey() @JsonKey() //^^^^^^^^^^