Macro. Update JsonSerializable to use throw instead of invalid code.

Bug: https://github.com/dart-lang/sdk/issues/55005
Change-Id: I7ba716576ef5c4cb3aef1e4bd10c70824d39964a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
This commit is contained in:
Konstantin Shcheglov 2024-02-26 18:22:47 +00:00
parent d310d84f7f
commit fe41579bf6

View file

@ -179,7 +179,7 @@ macro class FromJson implements ConstructorDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to deserialize type ${type.code.debugString}>');
"throw 'Unable to deserialize type ${type.code.debugString}'");
}
var typeDecl = await builder.typeDeclarationOf(type.identifier);
while (typeDecl is TypeAliasDeclaration) {
@ -192,7 +192,7 @@ macro class FromJson implements ConstructorDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to deserialize type ${type.code.debugString}>');
"throw 'Unable to deserialize type ${type.code.debugString}'");
}
typeDecl = await builder.typeDeclarationOf(aliasedType.identifier);
}
@ -204,7 +204,7 @@ macro class FromJson implements ConstructorDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to deserialize type ${type.code.debugString}>');
"throw 'Unable to deserialize type ${type.code.debugString}'");
}
// The static type of the expected type, without any type arguments.
@ -523,7 +523,7 @@ macro class ToJson implements MethodDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to serialize type ${type.code.debugString}>');
"throw 'Unable to serialize type ${type.code.debugString}'");
}
var typeDecl = await builder.typeDeclarationOf(type.identifier);
while (typeDecl is TypeAliasDeclaration) {
@ -535,7 +535,7 @@ macro class ToJson implements MethodDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to serialize type ${type.code.debugString}>');
"throw 'Unable to serialize type ${type.code.debugString}'");
}
typeDecl = await builder.typeDeclarationOf(aliasedType.identifier);
}
@ -546,7 +546,7 @@ macro class ToJson implements MethodDefinitionMacro {
target: type.asDiagnosticTarget),
Severity.error));
return RawCode.fromString(
'<Unable to serialize type ${type.code.debugString}>');
"throw 'Unable to serialize type ${type.code.debugString}'");
}
var typeDeclType = await builder.resolve(