diff --git a/templates/cc/msg.go b/templates/cc/msg.go index 81f336d17..46cd290fe 100644 --- a/templates/cc/msg.go +++ b/templates/cc/msg.go @@ -116,6 +116,11 @@ bool Validate(const {{ class . }}& m, pgv::ValidationMsg* err) { {{ range .NonOneOfFields }} {{- render (context .) -}} {{ end -}} + {{ range .SyntheticOneOfFields }} + if ({{ hasAccessor (context .) }}) { + {{ render (context .) }} + } + {{ end }} {{ range .RealOneOfs }} switch (m.{{ .Name }}_case()) { {{ range .Fields -}} diff --git a/templates/java/msg.go b/templates/java/msg.go index 0c58760da..2cf8fd3c0 100644 --- a/templates/java/msg.go +++ b/templates/java/msg.go @@ -15,6 +15,9 @@ const msgInnerTpl = ` {{- range .NonOneOfFields }} {{ renderConstants (context .) }} {{ end }} + {{ range .SyntheticOneOfFields }} + {{ renderConstants (context .) }} + {{ end }} {{ range .RealOneOfs }} {{ template "oneOfConst" . }} {{ end }} @@ -27,6 +30,11 @@ const msgInnerTpl = ` {{ range .NonOneOfFields -}} {{ render (context .) }} {{ end -}} + {{ range .SyntheticOneOfFields }} + if ({{ hasAccessor (context .) }}) { + {{ render (context .) }} + } + {{ end }} {{ range .RealOneOfs }} {{ template "oneOf" . }} {{- end -}}