encoding/protobuf: ensure predeclared identifiers are not masked

This was already done for other types, but not for types.

Change-Id: Ia044084a286f7e8ec9bc8c9f2bbdfb947806eba2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2801
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/protobuf/parse.go b/encoding/protobuf/parse.go
index 9f49916..3c8713d 100644
--- a/encoding/protobuf/parse.go
+++ b/encoding/protobuf/parse.go
@@ -274,7 +274,7 @@
 
 func (p *protoConverter) resolve(pos scanner.Position, name string, options []*proto.Option) string {
 	if s, ok := protoToCUE(name, options); ok {
-		return s
+		return p.uniqueTop(s)
 	}
 	if strings.HasPrefix(name, ".") {
 		return p.resolveTopScope(pos, name[1:], options)
diff --git a/encoding/protobuf/testdata/attributes.proto.out.cue b/encoding/protobuf/testdata/attributes.proto.out.cue
index 224e2e4..d678760 100644
--- a/encoding/protobuf/testdata/attributes.proto.out.cue
+++ b/encoding/protobuf/testdata/attributes.proto.out.cue
@@ -148,7 +148,7 @@
 
 	//  Holds attributes of type BYTES
 	bytes: {
-		<_>: bytes
+		<_>: __bytes
 	} @protobuf(8,type=map<sint32,bytes>)
 
 	//  Holds attributes of type STRING_MAP
@@ -157,6 +157,7 @@
 	} @protobuf(9,type=map<sint32,StringMap>,string_maps,"(gogoproto.nullable)=false")
 }
 __time = time
+__bytes = bytes
 
 //  A map of string to string. The keys and values in this map are dictionary
 //  indices (see the [Attributes][istio.mixer.v1.CompressedAttributes] message for an explanation)
diff --git a/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue b/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
index 3baa07a..feced59 100644
--- a/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
+++ b/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
@@ -148,7 +148,7 @@
 
 	//  Holds attributes of type BYTES
 	bytes: {
-		<_>: bytes
+		<_>: __bytes
 	} @protobuf(8,type=map<sint32,bytes>)
 
 	//  Holds attributes of type STRING_MAP
@@ -157,6 +157,7 @@
 	} @protobuf(9,type=map<sint32,StringMap>,string_maps,"(gogoproto.nullable)=false")
 }
 __time = time
+__bytes = bytes
 
 //  A map of string to string. The keys and values in this map are dictionary
 //  indices (see the [Attributes][istio.mixer.v1.CompressedAttributes] message for an explanation)