Skip to content

Commit b405072

Browse files
authored
fix(dart): Avoid shadowing contents field name (#3278)
If a message defines a `contents` field then it would be shadowed by a local variable in the generated `toString` method.
1 parent 8856c43 commit b405072

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/sidekick/dart/templates/lib/message.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ final class {{Codec.Name}} extends {{Codec.Model.Codec.ProtoPrefix}}ProtoMessage
8989
@override
9090
{{#Codec.HasToStringLines}}
9191
String toString() {
92-
final contents = [
92+
final $contents = [
9393
{{#Codec.ToStringLines}}
9494
{{{.}}}
9595
{{/Codec.ToStringLines}}
9696
].join(',');
97-
return '{{Name}}($contents)';
97+
return '{{Name}}(${$contents})';
9898
}
9999
{{/Codec.HasToStringLines}}
100100
{{^Codec.HasToStringLines}}

0 commit comments

Comments
 (0)