From 05e11b806f927ef0425a3e3f32e6d6792f65bb1c Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Tue, 4 Jun 2019 17:05:04 -0700 Subject: [PATCH] internal/impl: unexport ExtensionField.Desc CL/180577 removes direct access to the Desc field in v1. Since the only way to access the type is through {Has,Get,Set}Type, we can now unexport the field and change the underlying type. Change-Id: I6cc7018d4326c17228ba579d6161c5fb3f6d4127 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/180578 Reviewed-by: Damien Neil --- cmd/protoc-gen-go-grpc/testdata/go.mod | 2 +- cmd/protoc-gen-go/testdata/go.mod | 2 +- go.mod | 2 +- go.sum | 4 +++- internal/impl/codec_extension.go | 11 ++++------- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmd/protoc-gen-go-grpc/testdata/go.mod b/cmd/protoc-gen-go-grpc/testdata/go.mod index fb87f76d..5e8ee644 100644 --- a/cmd/protoc-gen-go-grpc/testdata/go.mod +++ b/cmd/protoc-gen-go-grpc/testdata/go.mod @@ -1,7 +1,7 @@ module google.golang.org/protobuf/cmd/protoc-gen-go-grpc/testdata require ( - github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4 + github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba google.golang.org/grpc v1.19.0 google.golang.org/protobuf v1.0.0 ) diff --git a/cmd/protoc-gen-go/testdata/go.mod b/cmd/protoc-gen-go/testdata/go.mod index c945b8a9..a766e71d 100644 --- a/cmd/protoc-gen-go/testdata/go.mod +++ b/cmd/protoc-gen-go/testdata/go.mod @@ -1,7 +1,7 @@ module google.golang.org/protobuf/cmd/protoc-gen-go/testdata require ( - github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4 + github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba google.golang.org/protobuf v1.0.0 ) diff --git a/go.mod b/go.mod index f458e000..5b9ac2e0 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module google.golang.org/protobuf go 1.9 require ( - github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4 + github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba github.com/google/go-cmp v0.3.0 ) diff --git a/go.sum b/go.sum index 0603b6fb..b955349e 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,9 @@ github.com/golang/protobuf v1.2.1-0.20190514181236-7800af189d76/go.mod h1:Zfz6qc github.com/golang/protobuf v1.2.1-0.20190515194842-7574ba03306e/go.mod h1:GjgUz9uwrRQmdPBBrFqiVbojAmlpy6ryM6DCzC+20rE= github.com/golang/protobuf v1.2.1-0.20190516201927-a2cd3ac1b343/go.mod h1:PScGDF2x230A126tLt9Ol9RjhXzbiPJrt/CogooD2mE= github.com/golang/protobuf v1.2.1-0.20190516215712-ae2eaafab405/go.mod h1:UmP8hhPKR5WWIjbT9v0JEVT+U0DBSjbW8KaZVeyFfRE= -github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4 h1:266Mauktp82G9qvMyYdGtx+yv9kmSkBSVw2BOgK8578= github.com/golang/protobuf v1.2.1-0.20190523175523-a1331f0b4ab4/go.mod h1:G+fNMoyvKWZDB7PCDHF+dXbH9OeE3+JoozCd9V7i66U= +github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba h1:P0A9EXL00gtVRHb/i9BrNgjZw4jpo4lhQh2PyziSET4= +github.com/golang/protobuf v1.2.1-0.20190605195750-76c9e09470ba/go.mod h1:S1YIJXvYHGRCG2UmZsOcElkAYfvZLg2sDRr9+Xu8JXU= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= google.golang.org/protobuf v0.0.0-20190514172829-e89e6244e0e8/go.mod h1:791zQGC15vDqjpmPRn1uGPu5oHy/Jzw/Q1n5JsgIIcY= @@ -11,3 +12,4 @@ google.golang.org/protobuf v0.0.0-20190514231807-cdb777356907/go.mod h1:HeRLsKXv google.golang.org/protobuf v0.0.0-20190516201745-40b83d67fc75/go.mod h1:jf+u8AHuKtkib+0J4/bQXPNzCmT3V9a02hVzYKtatuw= google.golang.org/protobuf v0.0.0-20190516215540-a95b29fbf623/go.mod h1:cWWmz5lsCWIcqGLROrKq5Lu231IJw2PzqOZ8cgspbfY= google.golang.org/protobuf v0.0.0-20190522194032-21ade498bd69/go.mod h1:cJytyYi/6qdwy/+gD49hmgHcwD7zhWxE/1KPEslaZ3M= +google.golang.org/protobuf v0.0.0-20190605195314-89d49632e5cf/go.mod h1:Btug4TBaP5wNYcb2zGKDTS7WMcaPPLuqEAKfEAZWYbo= diff --git a/internal/impl/codec_extension.go b/internal/impl/codec_extension.go index 69d5a96f..577f1df2 100644 --- a/internal/impl/codec_extension.go +++ b/internal/impl/codec_extension.go @@ -10,7 +10,6 @@ import ( "google.golang.org/protobuf/internal/encoding/wire" pref "google.golang.org/protobuf/reflect/protoreflect" - piface "google.golang.org/protobuf/runtime/protoiface" ) type extensionFieldInfo struct { @@ -46,9 +45,7 @@ func (mi *MessageInfo) extensionFieldInfo(xt pref.ExtensionType) *extensionField } type ExtensionField struct { - // Desc is the descriptor information for the extension field. - // It must be populated if value is populated. - Desc *piface.ExtensionDescV1 // TODO: unexport and switch to protoreflect.ExtensionType + typ pref.ExtensionType // value is either the value of GetValue, // or a *lazyExtensionValue that then returns the value of GetValue. @@ -56,13 +53,13 @@ type ExtensionField struct { } func (f ExtensionField) HasType() bool { - return f.Desc != nil + return f.typ != nil } func (f ExtensionField) GetType() pref.ExtensionType { - return legacyExtensionTypeFromDesc(f.Desc) + return f.typ } func (f *ExtensionField) SetType(t pref.ExtensionType) { - f.Desc = legacyExtensionDescFromType(t) + f.typ = t } // HasValue reports whether a value is set for the extension field.