Skip to content

Commit 07c14f1

Browse files
authored
proto: make InternalMessageInfo functional (#1129)
The InternalMessageInfo type only exists to implement the XXX methods on generated messages where those methods were only ever intended to be called by this module itself. Since v1.4.0, this module no longer relies on the XXX methods, so the InternalMessageInfo and its implementation is supposed to be dead code. Unfortunately, there are external usages that violate our compatibility agreement and either directly call the XXX methods or indirectly call it because some library type-asserts to the existence of these methods. This change adds minimal support for InternalMessageInfo by just calling out directly to the v2 implementation.
1 parent 00998c7 commit 07c14f1

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

proto/deprecated.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"errors"
1010
"fmt"
1111
"strconv"
12+
13+
protoV2 "google.golang.org/protobuf/proto"
1214
)
1315

1416
var (
@@ -82,11 +84,30 @@ func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32,
8284
return val, nil
8385
}
8486

85-
// Deprecated: Do not use.
87+
// Deprecated: Do not use; this type existed for intenal-use only.
8688
type InternalMessageInfo struct{}
8789

88-
func (*InternalMessageInfo) DiscardUnknown(Message) { panic("not implemented") }
89-
func (*InternalMessageInfo) Marshal([]byte, Message, bool) ([]byte, error) { panic("not implemented") }
90-
func (*InternalMessageInfo) Merge(Message, Message) { panic("not implemented") }
91-
func (*InternalMessageInfo) Size(Message) int { panic("not implemented") }
92-
func (*InternalMessageInfo) Unmarshal(Message, []byte) error { panic("not implemented") }
90+
// Deprecated: Do not use; this method existed for intenal-use only.
91+
func (*InternalMessageInfo) DiscardUnknown(m Message) {
92+
DiscardUnknown(m)
93+
}
94+
95+
// Deprecated: Do not use; this method existed for intenal-use only.
96+
func (*InternalMessageInfo) Marshal(b []byte, m Message, deterministic bool) ([]byte, error) {
97+
return protoV2.MarshalOptions{Deterministic: deterministic}.MarshalAppend(b, MessageV2(m))
98+
}
99+
100+
// Deprecated: Do not use; this method existed for intenal-use only.
101+
func (*InternalMessageInfo) Merge(dst, src Message) {
102+
protoV2.Merge(MessageV2(dst), MessageV2(src))
103+
}
104+
105+
// Deprecated: Do not use; this method existed for intenal-use only.
106+
func (*InternalMessageInfo) Size(m Message) int {
107+
return protoV2.Size(MessageV2(m))
108+
}
109+
110+
// Deprecated: Do not use; this method existed for intenal-use only.
111+
func (*InternalMessageInfo) Unmarshal(m Message, b []byte) error {
112+
return protoV2.UnmarshalOptions{Merge: true}.Unmarshal(b, MessageV2(m))
113+
}

0 commit comments

Comments
 (0)