Просмотр исходного кода

proto: move T->*T wrappers from internal/scalar to proto

Usage of these is pervasive in code which works with proto2, and proto2
will be with us for a long, long time to come. Move them to the proto
package.

Change-Id: I1b2e57429fd5a8f107a848a4492d20c27f304bd7
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185543
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Damien Neil 6 лет назад
Родитель
Сommit
a8a2cea3e7

+ 3 - 4
cmd/protoc-gen-go/annotation_test.go

@@ -11,7 +11,6 @@ import (
 
 	"google.golang.org/protobuf/encoding/prototext"
 	"google.golang.org/protobuf/internal/fieldnum"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 
 	"google.golang.org/protobuf/types/descriptorpb"
@@ -61,9 +60,9 @@ func TestAnnotations(t *testing.T) {
 		end := begin + len(want.text)
 		wantInfo.Annotation = append(wantInfo.Annotation, &descriptorpb.GeneratedCodeInfo_Annotation{
 			Path:       want.path,
-			Begin:      scalar.Int32(int32(begin)),
-			End:        scalar.Int32(int32(end)),
-			SourceFile: scalar.String("annotations/annotations.proto"),
+			Begin:      proto.Int32(int32(begin)),
+			End:        proto.Int32(int32(end)),
+			SourceFile: proto.String("annotations/annotations.proto"),
 		})
 	}
 	if !proto.Equal(gotInfo, wantInfo) {

+ 10 - 11
compiler/protogen/protogen.go

@@ -30,7 +30,6 @@ import (
 
 	"google.golang.org/protobuf/encoding/prototext"
 	"google.golang.org/protobuf/internal/fieldnum"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	"google.golang.org/protobuf/reflect/protodesc"
 	"google.golang.org/protobuf/reflect/protoreflect"
@@ -340,7 +339,7 @@ func (gen *Plugin) Error(err error) {
 func (gen *Plugin) Response() *pluginpb.CodeGeneratorResponse {
 	resp := &pluginpb.CodeGeneratorResponse{}
 	if gen.err != nil {
-		resp.Error = scalar.String(gen.err.Error())
+		resp.Error = proto.String(gen.err.Error())
 		return resp
 	}
 	for _, g := range gen.genFiles {
@@ -350,23 +349,23 @@ func (gen *Plugin) Response() *pluginpb.CodeGeneratorResponse {
 		content, err := g.Content()
 		if err != nil {
 			return &pluginpb.CodeGeneratorResponse{
-				Error: scalar.String(err.Error()),
+				Error: proto.String(err.Error()),
 			}
 		}
 		resp.File = append(resp.File, &pluginpb.CodeGeneratorResponse_File{
-			Name:    scalar.String(g.filename),
-			Content: scalar.String(string(content)),
+			Name:    proto.String(g.filename),
+			Content: proto.String(string(content)),
 		})
 		if gen.annotateCode && strings.HasSuffix(g.filename, ".go") {
 			meta, err := g.metaFile(content)
 			if err != nil {
 				return &pluginpb.CodeGeneratorResponse{
-					Error: scalar.String(err.Error()),
+					Error: proto.String(err.Error()),
 				}
 			}
 			resp.File = append(resp.File, &pluginpb.CodeGeneratorResponse_File{
-				Name:    scalar.String(g.filename + ".meta"),
-				Content: scalar.String(meta),
+				Name:    proto.String(g.filename + ".meta"),
+				Content: proto.String(meta),
 			})
 		}
 	}
@@ -1061,10 +1060,10 @@ func (g *GeneratedFile) metaFile(content []byte) (string, error) {
 		seenAnnotations[s] = true
 		for _, loc := range g.annotations[s] {
 			info.Annotation = append(info.Annotation, &descriptorpb.GeneratedCodeInfo_Annotation{
-				SourceFile: scalar.String(loc.SourceFile),
+				SourceFile: proto.String(loc.SourceFile),
 				Path:       loc.Path,
-				Begin:      scalar.Int32(int32(fset.Position(ident.Pos()).Offset)),
-				End:        scalar.Int32(int32(fset.Position(ident.End()).Offset)),
+				Begin:      proto.Int32(int32(fset.Position(ident.Pos()).Offset)),
+				End:        proto.Int32(int32(fset.Position(ident.End()).Offset)),
 			})
 		}
 	}

+ 24 - 24
compiler/protogen/protogen_test.go

@@ -10,7 +10,7 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-	"google.golang.org/protobuf/internal/scalar"
+	"google.golang.org/protobuf/proto"
 	"google.golang.org/protobuf/reflect/protoreflect"
 
 	"google.golang.org/protobuf/types/descriptorpb"
@@ -25,7 +25,7 @@ func TestPluginParameters(t *testing.T) {
 	}
 	const params = "integer=2"
 	_, err := New(&pluginpb.CodeGeneratorRequest{
-		Parameter: scalar.String(params),
+		Parameter: proto.String(params),
 	}, opts)
 	if err != nil {
 		t.Errorf("New(generator parameters %q): %v", params, err)
@@ -46,7 +46,7 @@ func TestPluginParameterErrors(t *testing.T) {
 			ParamFunc: flags.Set,
 		}
 		_, err := New(&pluginpb.CodeGeneratorRequest{
-			Parameter: scalar.String(parameter),
+			Parameter: proto.String(parameter),
 		}, opts)
 		if err == nil {
 			t.Errorf("New(generator parameters %q): want error, got nil", parameter)
@@ -58,14 +58,14 @@ func TestNoGoPackage(t *testing.T) {
 	gen, err := New(&pluginpb.CodeGeneratorRequest{
 		ProtoFile: []*descriptorpb.FileDescriptorProto{
 			{
-				Name:    scalar.String("testdata/go_package/no_go_package.proto"),
-				Syntax:  scalar.String(protoreflect.Proto3.String()),
-				Package: scalar.String("goproto.testdata"),
+				Name:    proto.String("testdata/go_package/no_go_package.proto"),
+				Syntax:  proto.String(protoreflect.Proto3.String()),
+				Package: proto.String("goproto.testdata"),
 			},
 			{
-				Name:       scalar.String("testdata/go_package/no_go_package_import.proto"),
-				Syntax:     scalar.String(protoreflect.Proto3.String()),
-				Package:    scalar.String("goproto.testdata"),
+				Name:       proto.String("testdata/go_package/no_go_package_import.proto"),
+				Syntax:     proto.String(protoreflect.Proto3.String()),
+				Package:    proto.String("goproto.testdata"),
 				Dependency: []string{"go_package/no_go_package.proto"},
 			},
 		},
@@ -167,13 +167,13 @@ TEST: %v
 			test.desc, test.parameter, filename, test.generate, test.goPackageOption)
 
 		req := &pluginpb.CodeGeneratorRequest{
-			Parameter: scalar.String(test.parameter),
+			Parameter: proto.String(test.parameter),
 			ProtoFile: []*descriptorpb.FileDescriptorProto{
 				{
-					Name:    scalar.String(filename),
-					Package: scalar.String(protoPackageName),
+					Name:    proto.String(filename),
+					Package: proto.String(protoPackageName),
 					Options: &descriptorpb.FileOptions{
-						GoPackage: scalar.String(test.goPackageOption),
+						GoPackage: proto.String(test.goPackageOption),
 					},
 				},
 			},
@@ -207,14 +207,14 @@ func TestPackageNameInference(t *testing.T) {
 	gen, err := New(&pluginpb.CodeGeneratorRequest{
 		ProtoFile: []*descriptorpb.FileDescriptorProto{
 			{
-				Name:    scalar.String("dir/file1.proto"),
-				Package: scalar.String("proto.package"),
+				Name:    proto.String("dir/file1.proto"),
+				Package: proto.String("proto.package"),
 			},
 			{
-				Name:    scalar.String("dir/file2.proto"),
-				Package: scalar.String("proto.package"),
+				Name:    proto.String("dir/file2.proto"),
+				Package: proto.String("proto.package"),
 				Options: &descriptorpb.FileOptions{
-					GoPackage: scalar.String("foo"),
+					GoPackage: proto.String("foo"),
 				},
 			},
 		},
@@ -234,17 +234,17 @@ func TestInconsistentPackageNames(t *testing.T) {
 	_, err := New(&pluginpb.CodeGeneratorRequest{
 		ProtoFile: []*descriptorpb.FileDescriptorProto{
 			{
-				Name:    scalar.String("dir/file1.proto"),
-				Package: scalar.String("proto.package"),
+				Name:    proto.String("dir/file1.proto"),
+				Package: proto.String("proto.package"),
 				Options: &descriptorpb.FileOptions{
-					GoPackage: scalar.String("golang.org/x/foo"),
+					GoPackage: proto.String("golang.org/x/foo"),
 				},
 			},
 			{
-				Name:    scalar.String("dir/file2.proto"),
-				Package: scalar.String("proto.package"),
+				Name:    proto.String("dir/file2.proto"),
+				Package: proto.String("proto.package"),
 				Options: &descriptorpb.FileOptions{
-					GoPackage: scalar.String("golang.org/x/foo;bar"),
+					GoPackage: proto.String("golang.org/x/foo;bar"),
 				},
 			},
 		},

+ 64 - 65
encoding/protojson/decode_test.go

@@ -12,7 +12,6 @@ import (
 	"google.golang.org/protobuf/encoding/testprotos/pb2"
 	"google.golang.org/protobuf/encoding/testprotos/pb3"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -65,21 +64,21 @@ func TestUnmarshal(t *testing.T) {
   "optString": ""
 }`,
 		wantMessage: &pb2.Scalars{
-			OptBool:     scalar.Bool(false),
-			OptInt32:    scalar.Int32(0),
-			OptInt64:    scalar.Int64(0),
-			OptUint32:   scalar.Uint32(0),
-			OptUint64:   scalar.Uint64(0),
-			OptSint32:   scalar.Int32(0),
-			OptSint64:   scalar.Int64(0),
-			OptFixed32:  scalar.Uint32(0),
-			OptFixed64:  scalar.Uint64(0),
-			OptSfixed32: scalar.Int32(0),
-			OptSfixed64: scalar.Int64(0),
-			OptFloat:    scalar.Float32(0),
-			OptDouble:   scalar.Float64(0),
+			OptBool:     proto.Bool(false),
+			OptInt32:    proto.Int32(0),
+			OptInt64:    proto.Int64(0),
+			OptUint32:   proto.Uint32(0),
+			OptUint64:   proto.Uint64(0),
+			OptSint32:   proto.Int32(0),
+			OptSint64:   proto.Int64(0),
+			OptFixed32:  proto.Uint32(0),
+			OptFixed64:  proto.Uint64(0),
+			OptSfixed32: proto.Int32(0),
+			OptSfixed64: proto.Int64(0),
+			OptFloat:    proto.Float32(0),
+			OptDouble:   proto.Float64(0),
 			OptBytes:    []byte{},
-			OptString:   scalar.String(""),
+			OptString:   proto.String(""),
 		},
 	}, {
 		desc:         "proto3 scalars set to zero values",
@@ -354,7 +353,7 @@ func TestUnmarshal(t *testing.T) {
 		inputMessage: &pb2.Scalars{},
 		inputText:    `{"optString": "谷歌"}`,
 		wantMessage: &pb2.Scalars{
-			OptString: scalar.String("谷歌"),
+			OptString: proto.String("谷歌"),
 		},
 	}, {
 		desc:         "string with invalid UTF-8",
@@ -540,9 +539,9 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: &pb2.Nests{
 			OptNested: &pb2.Nested{
-				OptString: scalar.String("nested message"),
+				OptString: proto.String("nested message"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested message"),
+					OptString: proto.String("another nested message"),
 				},
 			},
 		},
@@ -562,12 +561,12 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: &pb2.Nests{
 			Optgroup: &pb2.Nests_OptGroup{
-				OptString: scalar.String("inside a group"),
+				OptString: proto.String("inside a group"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("nested message inside a group"),
+					OptString: proto.String("nested message inside a group"),
 				},
 				Optnestedgroup: &pb2.Nests_OptGroup_OptNestedGroup{
-					OptFixed32: scalar.Uint32(47),
+					OptFixed32: proto.Uint32(47),
 				},
 			},
 		},
@@ -745,12 +744,12 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: &pb2.Nests{
 			RptNested: []*pb2.Nested{
 				{
-					OptString: scalar.String("repeat nested one"),
+					OptString: proto.String("repeat nested one"),
 				},
 				{
-					OptString: scalar.String("repeat nested two"),
+					OptString: proto.String("repeat nested two"),
 					OptNested: &pb2.Nested{
-						OptString: scalar.String("inside repeat nested two"),
+						OptString: proto.String("inside repeat nested two"),
 					},
 				},
 				{},
@@ -1001,7 +1000,7 @@ func TestUnmarshal(t *testing.T) {
   "reqString": "this is required"
 }`,
 		wantMessage: &pb2.PartialRequired{
-			ReqString: scalar.String("this is required"),
+			ReqString: proto.String("this is required"),
 		},
 	}, {
 		desc:         "required fields partially set",
@@ -1013,9 +1012,9 @@ func TestUnmarshal(t *testing.T) {
   "reqEnum": "ONE"
 }`,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(42),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(42),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		wantErr: true,
@@ -1030,9 +1029,9 @@ func TestUnmarshal(t *testing.T) {
   "reqEnum": "ONE"
 }`,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(42),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(42),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 	}, {
@@ -1047,10 +1046,10 @@ func TestUnmarshal(t *testing.T) {
   "reqNested": {}
 }`,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(42),
-			ReqDouble:   scalar.Float64(1.23),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(42),
+			ReqDouble:   proto.Float64(1.23),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 			ReqNested:   &pb2.Nested{},
 		},
@@ -1086,7 +1085,7 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: &pb2.IndirectRequired{
 			RptNested: []*pb2.NestedWithRequired{
 				{
-					ReqString: scalar.String("one"),
+					ReqString: proto.String("one"),
 				},
 				{},
 			},
@@ -1105,7 +1104,7 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: &pb2.IndirectRequired{
 			RptNested: []*pb2.NestedWithRequired{
 				{
-					ReqString: scalar.String("one"),
+					ReqString: proto.String("one"),
 				},
 				{},
 			},
@@ -1125,7 +1124,7 @@ func TestUnmarshal(t *testing.T) {
 			StrToNested: map[string]*pb2.NestedWithRequired{
 				"missing": &pb2.NestedWithRequired{},
 				"contains": &pb2.NestedWithRequired{
-					ReqString: scalar.String("here"),
+					ReqString: proto.String("here"),
 				},
 			},
 		},
@@ -1146,7 +1145,7 @@ func TestUnmarshal(t *testing.T) {
 			StrToNested: map[string]*pb2.NestedWithRequired{
 				"missing": &pb2.NestedWithRequired{},
 				"contains": &pb2.NestedWithRequired{
-					ReqString: scalar.String("here"),
+					ReqString: proto.String("here"),
 				},
 			},
 		},
@@ -1193,17 +1192,17 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_OptExtBool, true)
 			setExtension(m, pb2.E_OptExtString, "extension field")
 			setExtension(m, pb2.E_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -1225,9 +1224,9 @@ func TestUnmarshal(t *testing.T) {
 			setExtension(m, pb2.E_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_RptExtFixed32, &[]uint32{42, 47})
 			setExtension(m, pb2.E_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1251,9 +1250,9 @@ func TestUnmarshal(t *testing.T) {
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtString, "extension field")
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -1275,16 +1274,16 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtString, &[]string{"hello", "world"})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1310,13 +1309,13 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension_MessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("a messageset extension"),
+				OptString: proto.String("a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_NotMessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_ExtNested, &pb2.Nested{
-				OptString: scalar.String("just a regular extension"),
+				OptString: proto.String("just a regular extension"),
 			})
 			return m
 		}(),
@@ -1342,7 +1341,7 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: func() proto.Message {
 			m := &pb2.FakeMessageSet{}
 			setExtension(m, pb2.E_FakeMessageSetExtension_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1366,7 +1365,7 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("another not a messageset extension"),
+				OptString: proto.String("another not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1895,9 +1894,9 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1935,7 +1934,7 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				Deterministic: true,
@@ -1962,7 +1961,7 @@ func TestUnmarshal(t *testing.T) {
 }`,
 		wantMessage: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				Deterministic: true,
@@ -2365,7 +2364,7 @@ func TestUnmarshal(t *testing.T) {
 		wantMessage: &pb2.Nests{
 			RptNested: []*pb2.Nested{
 				{},
-				{OptString: scalar.String("hello")},
+				{OptString: proto.String("hello")},
 			},
 		},
 	}, {

+ 73 - 74
encoding/protojson/encode_test.go

@@ -13,7 +13,6 @@ import (
 	"google.golang.org/protobuf/encoding/protojson"
 	"google.golang.org/protobuf/internal/encoding/pack"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 	"google.golang.org/protobuf/runtime/protoiface"
@@ -52,21 +51,21 @@ func TestMarshal(t *testing.T) {
 	}, {
 		desc: "proto2 optional scalars set to zero values",
 		input: &pb2.Scalars{
-			OptBool:     scalar.Bool(false),
-			OptInt32:    scalar.Int32(0),
-			OptInt64:    scalar.Int64(0),
-			OptUint32:   scalar.Uint32(0),
-			OptUint64:   scalar.Uint64(0),
-			OptSint32:   scalar.Int32(0),
-			OptSint64:   scalar.Int64(0),
-			OptFixed32:  scalar.Uint32(0),
-			OptFixed64:  scalar.Uint64(0),
-			OptSfixed32: scalar.Int32(0),
-			OptSfixed64: scalar.Int64(0),
-			OptFloat:    scalar.Float32(0),
-			OptDouble:   scalar.Float64(0),
+			OptBool:     proto.Bool(false),
+			OptInt32:    proto.Int32(0),
+			OptInt64:    proto.Int64(0),
+			OptUint32:   proto.Uint32(0),
+			OptUint64:   proto.Uint64(0),
+			OptSint32:   proto.Int32(0),
+			OptSint64:   proto.Int64(0),
+			OptFixed32:  proto.Uint32(0),
+			OptFixed64:  proto.Uint64(0),
+			OptSfixed32: proto.Int32(0),
+			OptSfixed64: proto.Int64(0),
+			OptFloat:    proto.Float32(0),
+			OptDouble:   proto.Float64(0),
 			OptBytes:    []byte{},
-			OptString:   scalar.String(""),
+			OptString:   proto.String(""),
 		},
 		want: `{
   "optBool": false,
@@ -88,19 +87,19 @@ func TestMarshal(t *testing.T) {
 	}, {
 		desc: "proto2 optional scalars set to some values",
 		input: &pb2.Scalars{
-			OptBool:     scalar.Bool(true),
-			OptInt32:    scalar.Int32(0xff),
-			OptInt64:    scalar.Int64(0xdeadbeef),
-			OptUint32:   scalar.Uint32(47),
-			OptUint64:   scalar.Uint64(0xdeadbeef),
-			OptSint32:   scalar.Int32(-1001),
-			OptSint64:   scalar.Int64(-0xffff),
-			OptFixed64:  scalar.Uint64(64),
-			OptSfixed32: scalar.Int32(-32),
-			OptFloat:    scalar.Float32(1.02),
-			OptDouble:   scalar.Float64(1.234),
+			OptBool:     proto.Bool(true),
+			OptInt32:    proto.Int32(0xff),
+			OptInt64:    proto.Int64(0xdeadbeef),
+			OptUint32:   proto.Uint32(47),
+			OptUint64:   proto.Uint64(0xdeadbeef),
+			OptSint32:   proto.Int32(-1001),
+			OptSint64:   proto.Int64(-0xffff),
+			OptFixed64:  proto.Uint64(64),
+			OptSfixed32: proto.Int32(-32),
+			OptFloat:    proto.Float32(1.02),
+			OptDouble:   proto.Float64(1.234),
 			OptBytes:    []byte("谷歌"),
-			OptString:   scalar.String("谷歌"),
+			OptString:   proto.String("谷歌"),
 		},
 		want: `{
   "optBool": true,
@@ -282,9 +281,9 @@ func TestMarshal(t *testing.T) {
 		desc: "proto2 nested messages",
 		input: &pb2.Nests{
 			OptNested: &pb2.Nested{
-				OptString: scalar.String("nested message"),
+				OptString: proto.String("nested message"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested message"),
+					OptString: proto.String("another nested message"),
 				},
 			},
 		},
@@ -300,12 +299,12 @@ func TestMarshal(t *testing.T) {
 		desc: "proto2 groups",
 		input: &pb2.Nests{
 			Optgroup: &pb2.Nests_OptGroup{
-				OptString: scalar.String("inside a group"),
+				OptString: proto.String("inside a group"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("nested message inside a group"),
+					OptString: proto.String("nested message inside a group"),
 				},
 				Optnestedgroup: &pb2.Nests_OptGroup_OptNestedGroup{
-					OptFixed32: scalar.Uint32(47),
+					OptFixed32: proto.Uint32(47),
 				},
 			},
 		},
@@ -515,12 +514,12 @@ func TestMarshal(t *testing.T) {
 		input: &pb2.Nests{
 			RptNested: []*pb2.Nested{
 				{
-					OptString: scalar.String("repeat nested one"),
+					OptString: proto.String("repeat nested one"),
 				},
 				{
-					OptString: scalar.String("repeat nested two"),
+					OptString: proto.String("repeat nested two"),
 					OptNested: &pb2.Nested{
-						OptString: scalar.String("inside repeat nested two"),
+						OptString: proto.String("inside repeat nested two"),
 					},
 				},
 				{},
@@ -702,10 +701,10 @@ func TestMarshal(t *testing.T) {
 	}, {
 		desc: "required fields partially set",
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0),
-			ReqDouble:   scalar.Float64(1.23),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0),
+			ReqDouble:   proto.Float64(1.23),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		want: `{
@@ -720,10 +719,10 @@ func TestMarshal(t *testing.T) {
 		desc: "required fields not set with AllowPartial",
 		mo:   protojson.MarshalOptions{AllowPartial: true},
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0),
-			ReqDouble:   scalar.Float64(1.23),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0),
+			ReqDouble:   proto.Float64(1.23),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		want: `{
@@ -736,10 +735,10 @@ func TestMarshal(t *testing.T) {
 	}, {
 		desc: "required fields all set",
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0),
-			ReqDouble:   scalar.Float64(1.23),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0),
+			ReqDouble:   proto.Float64(1.23),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 			ReqNested:   &pb2.Nested{},
 		},
@@ -859,7 +858,7 @@ func TestMarshal(t *testing.T) {
 		desc: "unknown fields are ignored",
 		input: func() proto.Message {
 			m := &pb2.Scalars{
-				OptString: scalar.String("no unknowns"),
+				OptString: proto.String("no unknowns"),
 			}
 			m.ProtoReflect().SetUnknown(pack.Message{
 				pack.Tag{101, pack.BytesType}, pack.String("hello world"),
@@ -881,17 +880,17 @@ func TestMarshal(t *testing.T) {
 		desc: "extensions of non-repeated fields",
 		input: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_OptExtBool, true)
 			setExtension(m, pb2.E_OptExtString, "extension field")
 			setExtension(m, pb2.E_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -917,9 +916,9 @@ func TestMarshal(t *testing.T) {
 			setExtension(m, pb2.E_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_RptExtFixed32, &[]uint32{42, 47})
 			setExtension(m, pb2.E_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -953,9 +952,9 @@ func TestMarshal(t *testing.T) {
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtString, "extension field")
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -975,16 +974,16 @@ func TestMarshal(t *testing.T) {
 		desc: "extensions of repeated fields in another message",
 		input: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtString, &[]string{"hello", "world"})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1018,13 +1017,13 @@ func TestMarshal(t *testing.T) {
 		input: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension_MessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("a messageset extension"),
+				OptString: proto.String("a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_NotMessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_ExtNested, &pb2.Nested{
-				OptString: scalar.String("just a regular extension"),
+				OptString: proto.String("just a regular extension"),
 			})
 			return m
 		}(),
@@ -1044,7 +1043,7 @@ func TestMarshal(t *testing.T) {
 		input: func() proto.Message {
 			m := &pb2.FakeMessageSet{}
 			setExtension(m, pb2.E_FakeMessageSetExtension_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1058,7 +1057,7 @@ func TestMarshal(t *testing.T) {
 		input: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("another not a messageset extension"),
+				OptString: proto.String("another not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1495,9 +1494,9 @@ func TestMarshal(t *testing.T) {
 		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1537,7 +1536,7 @@ func TestMarshal(t *testing.T) {
 		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				AllowPartial:  true,
@@ -1563,7 +1562,7 @@ func TestMarshal(t *testing.T) {
 		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				AllowPartial:  true,
@@ -1588,7 +1587,7 @@ func TestMarshal(t *testing.T) {
 		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("abc\xff"),
+				OptString: proto.String("abc\xff"),
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
 			if err != nil {

+ 70 - 71
encoding/prototext/decode_test.go

@@ -10,7 +10,6 @@ import (
 
 	"google.golang.org/protobuf/encoding/prototext"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -51,21 +50,21 @@ opt_bytes: ""
 opt_string: ""
 `,
 		wantMessage: &pb2.Scalars{
-			OptBool:     scalar.Bool(false),
-			OptInt32:    scalar.Int32(0),
-			OptInt64:    scalar.Int64(0),
-			OptUint32:   scalar.Uint32(0),
-			OptUint64:   scalar.Uint64(0),
-			OptSint32:   scalar.Int32(0),
-			OptSint64:   scalar.Int64(0),
-			OptFixed32:  scalar.Uint32(0),
-			OptFixed64:  scalar.Uint64(0),
-			OptSfixed32: scalar.Int32(0),
-			OptSfixed64: scalar.Int64(0),
-			OptFloat:    scalar.Float32(0),
-			OptDouble:   scalar.Float64(0),
+			OptBool:     proto.Bool(false),
+			OptInt32:    proto.Int32(0),
+			OptInt64:    proto.Int64(0),
+			OptUint32:   proto.Uint32(0),
+			OptUint64:   proto.Uint64(0),
+			OptSint32:   proto.Int32(0),
+			OptSint64:   proto.Int64(0),
+			OptFixed32:  proto.Uint32(0),
+			OptFixed64:  proto.Uint64(0),
+			OptSfixed32: proto.Int32(0),
+			OptSfixed64: proto.Int64(0),
+			OptFloat:    proto.Float32(0),
+			OptDouble:   proto.Float64(0),
 			OptBytes:    []byte{},
-			OptString:   scalar.String(""),
+			OptString:   proto.String(""),
 		},
 	}, {
 		desc:         "proto3 scalars set to zero values",
@@ -105,19 +104,19 @@ opt_bytes: "\xe8\xb0\xb7\xe6\xad\x8c"
 opt_string: "谷歌"
 `,
 		wantMessage: &pb2.Scalars{
-			OptBool:     scalar.Bool(true),
-			OptInt32:    scalar.Int32(0xff),
-			OptInt64:    scalar.Int64(0xdeadbeef),
-			OptUint32:   scalar.Uint32(0xff),
-			OptUint64:   scalar.Uint64(0xdeadbeef),
-			OptSint32:   scalar.Int32(-1001),
-			OptSint64:   scalar.Int64(-0xffff),
-			OptFixed64:  scalar.Uint64(64),
-			OptSfixed32: scalar.Int32(-32),
-			OptFloat:    scalar.Float32(1.234),
-			OptDouble:   scalar.Float64(1.23e100),
+			OptBool:     proto.Bool(true),
+			OptInt32:    proto.Int32(0xff),
+			OptInt64:    proto.Int64(0xdeadbeef),
+			OptUint32:   proto.Uint32(0xff),
+			OptUint64:   proto.Uint64(0xdeadbeef),
+			OptSint32:   proto.Int32(-1001),
+			OptSint64:   proto.Int64(-0xffff),
+			OptFixed64:  proto.Uint64(64),
+			OptSfixed32: proto.Int32(-32),
+			OptFloat:    proto.Float32(1.234),
+			OptDouble:   proto.Float64(1.23e100),
 			OptBytes:    []byte("\xe8\xb0\xb7\xe6\xad\x8c"),
-			OptString:   scalar.String("谷歌"),
+			OptString:   proto.String("谷歌"),
 		},
 	}, {
 		desc:         "case sensitive",
@@ -425,9 +424,9 @@ opt_nested: {
 `,
 		wantMessage: &pb2.Nests{
 			OptNested: &pb2.Nested{
-				OptString: scalar.String("nested message"),
+				OptString: proto.String("nested message"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested message"),
+					OptString: proto.String("another nested message"),
 				},
 			},
 		},
@@ -589,12 +588,12 @@ rpt_nested: {}
 		wantMessage: &pb2.Nests{
 			RptNested: []*pb2.Nested{
 				{
-					OptString: scalar.String("repeat nested one"),
+					OptString: proto.String("repeat nested one"),
 				},
 				{
-					OptString: scalar.String("repeat nested two"),
+					OptString: proto.String("repeat nested two"),
 					OptNested: &pb2.Nested{
-						OptString: scalar.String("inside repeat nested two"),
+						OptString: proto.String("inside repeat nested two"),
 					},
 				},
 				{},
@@ -968,7 +967,7 @@ int32_to_str: {
 		inputMessage: &pb2.PartialRequired{},
 		inputText:    "req_string: 'this is required'",
 		wantMessage: &pb2.PartialRequired{
-			ReqString: scalar.String("this is required"),
+			ReqString: proto.String("this is required"),
 		},
 	}, {
 		desc:         "required fields partially set",
@@ -980,9 +979,9 @@ req_string: "hello"
 req_enum: ONE
 `,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0xbeefcafe),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0xbeefcafe),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		wantErr: true,
@@ -997,9 +996,9 @@ req_string: "hello"
 req_enum: ONE
 `,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0xbeefcafe),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0xbeefcafe),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 	}, {
@@ -1014,10 +1013,10 @@ req_enum: ONE
 req_nested: {}
 `,
 		wantMessage: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0),
-			ReqDouble:   scalar.Float64(0),
-			ReqString:   scalar.String(""),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0),
+			ReqDouble:   proto.Float64(0),
+			ReqString:   proto.String(""),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 			ReqNested:   &pb2.Nested{},
 		},
@@ -1049,7 +1048,7 @@ rpt_nested: {}
 		wantMessage: &pb2.IndirectRequired{
 			RptNested: []*pb2.NestedWithRequired{
 				{
-					ReqString: scalar.String("one"),
+					ReqString: proto.String("one"),
 				},
 				{},
 			},
@@ -1068,7 +1067,7 @@ rpt_nested: {}
 		wantMessage: &pb2.IndirectRequired{
 			RptNested: []*pb2.NestedWithRequired{
 				{
-					ReqString: scalar.String("one"),
+					ReqString: proto.String("one"),
 				},
 				{},
 			},
@@ -1091,7 +1090,7 @@ str_to_nested: {
 			StrToNested: map[string]*pb2.NestedWithRequired{
 				"missing": &pb2.NestedWithRequired{},
 				"contains": &pb2.NestedWithRequired{
-					ReqString: scalar.String("here"),
+					ReqString: proto.String("here"),
 				},
 			},
 		},
@@ -1115,7 +1114,7 @@ str_to_nested: {
 			StrToNested: map[string]*pb2.NestedWithRequired{
 				"missing": &pb2.NestedWithRequired{},
 				"contains": &pb2.NestedWithRequired{
-					ReqString: scalar.String("here"),
+					ReqString: proto.String("here"),
 				},
 			},
 		},
@@ -1164,17 +1163,17 @@ opt_int32: 42
 `,
 		wantMessage: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_OptExtBool, true)
 			setExtension(m, pb2.E_OptExtString, "extension field")
 			setExtension(m, pb2.E_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -1207,9 +1206,9 @@ opt_int32: 42
 			setExtension(m, pb2.E_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_RptExtFixed32, &[]uint32{42, 47})
 			setExtension(m, pb2.E_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1232,9 +1231,9 @@ opt_int32: 42
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtString, "extension field")
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -1262,16 +1261,16 @@ opt_int32: 42
 `,
 		wantMessage: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtString, &[]string{"hello", "world"})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1297,13 +1296,13 @@ opt_int32: 42
 		wantMessage: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension_MessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("a messageset extension"),
+				OptString: proto.String("a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_NotMessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_ExtNested, &pb2.Nested{
-				OptString: scalar.String("just a regular extension"),
+				OptString: proto.String("just a regular extension"),
 			})
 			return m
 		}(),
@@ -1318,7 +1317,7 @@ opt_int32: 42
 		wantMessage: func() proto.Message {
 			m := &pb2.FakeMessageSet{}
 			setExtension(m, pb2.E_FakeMessageSetExtension_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1341,7 +1340,7 @@ opt_int32: 42
 		wantMessage: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("another not a messageset extension"),
+				OptString: proto.String("another not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1386,9 +1385,9 @@ value: "some bytes"
 `,
 		wantMessage: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1423,7 +1422,7 @@ value: "some bytes"
 `,
 		wantMessage: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				AllowPartial:  true,

+ 76 - 77
encoding/prototext/encode_test.go

@@ -13,7 +13,6 @@ import (
 	"google.golang.org/protobuf/internal/detrand"
 	"google.golang.org/protobuf/internal/encoding/pack"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 	"google.golang.org/protobuf/runtime/protoiface"
@@ -51,21 +50,21 @@ func TestMarshal(t *testing.T) {
 	}, {
 		desc: "proto2 optional scalars set to zero values",
 		input: &pb2.Scalars{
-			OptBool:     scalar.Bool(false),
-			OptInt32:    scalar.Int32(0),
-			OptInt64:    scalar.Int64(0),
-			OptUint32:   scalar.Uint32(0),
-			OptUint64:   scalar.Uint64(0),
-			OptSint32:   scalar.Int32(0),
-			OptSint64:   scalar.Int64(0),
-			OptFixed32:  scalar.Uint32(0),
-			OptFixed64:  scalar.Uint64(0),
-			OptSfixed32: scalar.Int32(0),
-			OptSfixed64: scalar.Int64(0),
-			OptFloat:    scalar.Float32(0),
-			OptDouble:   scalar.Float64(0),
+			OptBool:     proto.Bool(false),
+			OptInt32:    proto.Int32(0),
+			OptInt64:    proto.Int64(0),
+			OptUint32:   proto.Uint32(0),
+			OptUint64:   proto.Uint64(0),
+			OptSint32:   proto.Int32(0),
+			OptSint64:   proto.Int64(0),
+			OptFixed32:  proto.Uint32(0),
+			OptFixed64:  proto.Uint64(0),
+			OptSfixed32: proto.Int32(0),
+			OptSfixed64: proto.Int64(0),
+			OptFloat:    proto.Float32(0),
+			OptDouble:   proto.Float64(0),
 			OptBytes:    []byte{},
-			OptString:   scalar.String(""),
+			OptString:   proto.String(""),
 		},
 		want: `opt_bool: false
 opt_int32: 0
@@ -106,19 +105,19 @@ opt_string: ""
 	}, {
 		desc: "proto2 optional scalars set to some values",
 		input: &pb2.Scalars{
-			OptBool:     scalar.Bool(true),
-			OptInt32:    scalar.Int32(0xff),
-			OptInt64:    scalar.Int64(0xdeadbeef),
-			OptUint32:   scalar.Uint32(47),
-			OptUint64:   scalar.Uint64(0xdeadbeef),
-			OptSint32:   scalar.Int32(-1001),
-			OptSint64:   scalar.Int64(-0xffff),
-			OptFixed64:  scalar.Uint64(64),
-			OptSfixed32: scalar.Int32(-32),
-			OptFloat:    scalar.Float32(1.02),
-			OptDouble:   scalar.Float64(1.0199999809265137),
+			OptBool:     proto.Bool(true),
+			OptInt32:    proto.Int32(0xff),
+			OptInt64:    proto.Int64(0xdeadbeef),
+			OptUint32:   proto.Uint32(47),
+			OptUint64:   proto.Uint64(0xdeadbeef),
+			OptSint32:   proto.Int32(-1001),
+			OptSint64:   proto.Int64(-0xffff),
+			OptFixed64:  proto.Uint64(64),
+			OptSfixed32: proto.Int32(-32),
+			OptFloat:    proto.Float32(1.02),
+			OptDouble:   proto.Float64(1.0199999809265137),
 			OptBytes:    []byte("\xe8\xb0\xb7\xe6\xad\x8c"),
-			OptString:   scalar.String("谷歌"),
+			OptString:   proto.String("谷歌"),
 		},
 		want: `opt_bool: true
 opt_int32: 255
@@ -271,9 +270,9 @@ OptGroup: {}
 		desc: "proto2 nested messages",
 		input: &pb2.Nests{
 			OptNested: &pb2.Nested{
-				OptString: scalar.String("nested message"),
+				OptString: proto.String("nested message"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested message"),
+					OptString: proto.String("another nested message"),
 				},
 			},
 		},
@@ -288,12 +287,12 @@ OptGroup: {}
 		desc: "proto2 groups",
 		input: &pb2.Nests{
 			Optgroup: &pb2.Nests_OptGroup{
-				OptString: scalar.String("inside a group"),
+				OptString: proto.String("inside a group"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("nested message inside a group"),
+					OptString: proto.String("nested message inside a group"),
 				},
 				Optnestedgroup: &pb2.Nests_OptGroup_OptNestedGroup{
-					OptFixed32: scalar.Uint32(47),
+					OptFixed32: proto.Uint32(47),
 				},
 			},
 		},
@@ -483,12 +482,12 @@ rpt_nested_enum: DIEZ
 		input: &pb2.Nests{
 			RptNested: []*pb2.Nested{
 				{
-					OptString: scalar.String("repeat nested one"),
+					OptString: proto.String("repeat nested one"),
 				},
 				{
-					OptString: scalar.String("repeat nested two"),
+					OptString: proto.String("repeat nested two"),
 					OptNested: &pb2.Nested{
-						OptString: scalar.String("inside repeat nested two"),
+						OptString: proto.String("inside repeat nested two"),
 					},
 				},
 				{},
@@ -691,10 +690,10 @@ str_to_oneofs: {
 	}, {
 		desc: "required fields partially set",
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0xbeefcafe),
-			ReqDouble:   scalar.Float64(math.NaN()),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0xbeefcafe),
+			ReqDouble:   proto.Float64(math.NaN()),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		want: `req_bool: false
@@ -708,10 +707,10 @@ req_enum: ONE
 		desc: "required fields not set with AllowPartial",
 		mo:   prototext.MarshalOptions{AllowPartial: true},
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0xbeefcafe),
-			ReqDouble:   scalar.Float64(math.NaN()),
-			ReqString:   scalar.String("hello"),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0xbeefcafe),
+			ReqDouble:   proto.Float64(math.NaN()),
+			ReqString:   proto.String("hello"),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 		},
 		want: `req_bool: false
@@ -723,10 +722,10 @@ req_enum: ONE
 	}, {
 		desc: "required fields all set",
 		input: &pb2.Requireds{
-			ReqBool:     scalar.Bool(false),
-			ReqSfixed64: scalar.Int64(0),
-			ReqDouble:   scalar.Float64(1.23),
-			ReqString:   scalar.String(""),
+			ReqBool:     proto.Bool(false),
+			ReqSfixed64: proto.Int64(0),
+			ReqDouble:   proto.Float64(1.23),
+			ReqString:   proto.String(""),
 			ReqEnum:     pb2.Enum_ONE.Enum(),
 			ReqNested:   &pb2.Nested{},
 		},
@@ -829,7 +828,7 @@ req_nested: {}
 		desc: "unknown varint and fixed types",
 		input: func() proto.Message {
 			m := &pb2.Scalars{
-				OptString: scalar.String("this message contains unknown fields"),
+				OptString: proto.String("this message contains unknown fields"),
 			}
 			m.ProtoReflect().SetUnknown(pack.Message{
 				pack.Tag{101, pack.VarintType}, pack.Bool(true),
@@ -900,17 +899,17 @@ req_nested: {}
 		desc: "extensions of non-repeated fields",
 		input: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_OptExtBool, true)
 			setExtension(m, pb2.E_OptExtString, "extension field")
 			setExtension(m, pb2.E_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -941,10 +940,10 @@ opt_int32: 42
 		input: func() proto.Message {
 			m := &pb2.Extensions{}
 			setExtension(m, pb2.E_OptExtPartial, &pb2.PartialRequired{
-				OptString: scalar.String("partial1"),
+				OptString: proto.String("partial1"),
 			})
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtPartial, &pb2.PartialRequired{
-				OptString: scalar.String("partial2"),
+				OptString: proto.String("partial2"),
 			})
 			return m
 		}(),
@@ -962,7 +961,7 @@ opt_int32: 42
 		input: func() proto.Message {
 			m := &pb2.Extensions{}
 			setExtension(m, pb2.E_OptExtPartial, &pb2.PartialRequired{
-				OptString: scalar.String("partial1"),
+				OptString: proto.String("partial1"),
 			})
 			return m
 		}(),
@@ -977,9 +976,9 @@ opt_int32: 42
 			setExtension(m, pb2.E_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_RptExtFixed32, &[]uint32{42, 47})
 			setExtension(m, pb2.E_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1006,9 +1005,9 @@ opt_int32: 42
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtString, "extension field")
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtEnum, pb2.Enum_TEN)
 			setExtension(m, pb2.E_ExtensionsContainer_OptExtNested, &pb2.Nested{
-				OptString: scalar.String("nested in an extension"),
+				OptString: proto.String("nested in an extension"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("another nested in an extension"),
+					OptString: proto.String("another nested in an extension"),
 				},
 			})
 			return m
@@ -1027,16 +1026,16 @@ opt_int32: 42
 		desc: "extensions of repeated fields in another message",
 		input: func() proto.Message {
 			m := &pb2.Extensions{
-				OptString: scalar.String("non-extension field"),
-				OptBool:   scalar.Bool(true),
-				OptInt32:  scalar.Int32(42),
+				OptString: proto.String("non-extension field"),
+				OptBool:   proto.Bool(true),
+				OptInt32:  proto.Int32(42),
 			}
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtEnum, &[]pb2.Enum{pb2.Enum_TEN, 101, pb2.Enum_ONE})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtString, &[]string{"hello", "world"})
 			setExtension(m, pb2.E_ExtensionsContainer_RptExtNested, &[]*pb2.Nested{
-				&pb2.Nested{OptString: scalar.String("one")},
-				&pb2.Nested{OptString: scalar.String("two")},
-				&pb2.Nested{OptString: scalar.String("three")},
+				&pb2.Nested{OptString: proto.String("one")},
+				&pb2.Nested{OptString: proto.String("two")},
+				&pb2.Nested{OptString: proto.String("three")},
 			})
 			return m
 		}(),
@@ -1063,13 +1062,13 @@ opt_int32: 42
 		input: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension_MessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("a messageset extension"),
+				OptString: proto.String("a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_NotMessageSetExtension, &pb2.MessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			setExtension(m, pb2.E_MessageSetExtension_ExtNested, &pb2.Nested{
-				OptString: scalar.String("just a regular extension"),
+				OptString: proto.String("just a regular extension"),
 			})
 			return m
 		}(),
@@ -1088,7 +1087,7 @@ opt_int32: 42
 		input: func() proto.Message {
 			m := &pb2.FakeMessageSet{}
 			setExtension(m, pb2.E_FakeMessageSetExtension_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("not a messageset extension"),
+				OptString: proto.String("not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1101,7 +1100,7 @@ opt_int32: 42
 		input: func() proto.Message {
 			m := &pb2.MessageSet{}
 			setExtension(m, pb2.E_MessageSetExtension, &pb2.FakeMessageSetExtension{
-				OptString: scalar.String("another not a messageset extension"),
+				OptString: proto.String("another not a messageset extension"),
 			})
 			return m
 		}(),
@@ -1116,9 +1115,9 @@ opt_int32: 42
 		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1140,9 +1139,9 @@ value: "\n\x13embedded inside Any\x12\x0b\n\tinception"
 		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1168,7 +1167,7 @@ value: "\n\x13embedded inside Any\x12\x0b\n\tinception"
 		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 			}
 			b, err := proto.MarshalOptions{
 				AllowPartial:  true,

+ 5 - 6
encoding/prototext/other_test.go

@@ -10,7 +10,6 @@ import (
 	"google.golang.org/protobuf/encoding/prototext"
 	"google.golang.org/protobuf/internal/impl"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -155,9 +154,9 @@ func TestRoundTrip(t *testing.T) {
 		resolver: preg.NewTypes(),
 		message: func() proto.Message {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -176,9 +175,9 @@ func TestRoundTrip(t *testing.T) {
 		resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
 		message: func() *pb2.KnownTypes {
 			m := &pb2.Nested{
-				OptString: scalar.String("embedded inside Any"),
+				OptString: proto.String("embedded inside Any"),
 				OptNested: &pb2.Nested{
-					OptString: scalar.String("inception"),
+					OptString: proto.String("inception"),
 				},
 			}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -201,7 +200,7 @@ func TestRoundTrip(t *testing.T) {
 		}(),
 		message: func() *pb2.KnownTypes {
 			m1 := &pb2.Nested{
-				OptString: scalar.String("message inside Any of another Any field"),
+				OptString: proto.String("message inside Any of another Any field"),
 			}
 			b1, err := proto.MarshalOptions{Deterministic: true}.Marshal(m1)
 			if err != nil {

+ 8 - 8
internal/cmd/pbdump/pbdump.go

@@ -19,7 +19,7 @@ import (
 
 	"google.golang.org/protobuf/internal/encoding/pack"
 	"google.golang.org/protobuf/internal/encoding/wire"
-	"google.golang.org/protobuf/internal/scalar"
+	"google.golang.org/protobuf/proto"
 	"google.golang.org/protobuf/reflect/protodesc"
 	"google.golang.org/protobuf/reflect/protoreflect"
 
@@ -203,8 +203,8 @@ func (fs fields) set(prefix, s string, k protoreflect.Kind) error {
 // Descriptor returns the field tree as a message descriptor.
 func (fs fields) Descriptor() (protoreflect.MessageDescriptor, error) {
 	fd, err := protodesc.NewFile(&descriptorpb.FileDescriptorProto{
-		Name:        scalar.String("dump.proto"),
-		Syntax:      scalar.String("proto2"),
+		Name:        proto.String("dump.proto"),
+		Syntax:      proto.String("proto2"),
 		MessageType: []*descriptorpb.DescriptorProto{fs.messageDescriptor("X")},
 	}, nil)
 	if err != nil {
@@ -213,15 +213,15 @@ func (fs fields) Descriptor() (protoreflect.MessageDescriptor, error) {
 	return fd.Messages().Get(0), nil
 }
 func (fs fields) messageDescriptor(name protoreflect.FullName) *descriptorpb.DescriptorProto {
-	m := &descriptorpb.DescriptorProto{Name: scalar.String(string(name.Name()))}
+	m := &descriptorpb.DescriptorProto{Name: proto.String(string(name.Name()))}
 	for _, n := range fs.sortedNums() {
 		k := fs[n].kind
 		if !k.IsValid() {
 			k = protoreflect.MessageKind
 		}
 		f := &descriptorpb.FieldDescriptorProto{
-			Name:   scalar.String(fmt.Sprintf("x%d", n)),
-			Number: scalar.Int32(int32(n)),
+			Name:   proto.String(fmt.Sprintf("x%d", n)),
+			Number: proto.Int32(int32(n)),
 			Label:  descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum(),
 			Type:   descriptorpb.FieldDescriptorProto_Type(k).Enum(),
 		}
@@ -232,10 +232,10 @@ func (fs fields) messageDescriptor(name protoreflect.FullName) *descriptorpb.Des
 			protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind, protoreflect.FloatKind,
 			protoreflect.Sfixed64Kind, protoreflect.Fixed64Kind, protoreflect.DoubleKind:
 			f.Label = descriptorpb.FieldDescriptorProto_LABEL_REPEATED.Enum()
-			f.Options = &descriptorpb.FieldOptions{Packed: scalar.Bool(true)}
+			f.Options = &descriptorpb.FieldOptions{Packed: proto.Bool(true)}
 		case protoreflect.MessageKind, protoreflect.GroupKind:
 			s := name.Append(protoreflect.Name(fmt.Sprintf("X%d", n)))
-			f.TypeName = scalar.String(string("." + s))
+			f.TypeName = proto.String(string("." + s))
 			m.NestedType = append(m.NestedType, fs[n].sub.messageDescriptor(s))
 		}
 		m.Field = append(m.Field, f)

+ 83 - 84
internal/filedesc/desc_test.go

@@ -15,7 +15,6 @@ import (
 	"github.com/google/go-cmp/cmp"
 	detrand "google.golang.org/protobuf/internal/detrand"
 	"google.golang.org/protobuf/internal/filedesc"
-	scalar "google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	pdesc "google.golang.org/protobuf/reflect/protodesc"
 	pref "google.golang.org/protobuf/reflect/protoreflect"
@@ -32,161 +31,161 @@ func init() {
 
 func TestFile(t *testing.T) {
 	f1 := &descriptorpb.FileDescriptorProto{
-		Syntax:  scalar.String("proto2"),
-		Name:    scalar.String("path/to/file.proto"),
-		Package: scalar.String("test"),
-		Options: &descriptorpb.FileOptions{Deprecated: scalar.Bool(true)},
+		Syntax:  proto.String("proto2"),
+		Name:    proto.String("path/to/file.proto"),
+		Package: proto.String("test"),
+		Options: &descriptorpb.FileOptions{Deprecated: proto.Bool(true)},
 		MessageType: []*descriptorpb.DescriptorProto{{
-			Name: scalar.String("A"),
+			Name: proto.String("A"),
 			Options: &descriptorpb.MessageOptions{
-				Deprecated: scalar.Bool(true),
+				Deprecated: proto.Bool(true),
 			},
 		}, {
-			Name: scalar.String("B"),
+			Name: proto.String("B"),
 			Field: []*descriptorpb.FieldDescriptorProto{{
-				Name:         scalar.String("field_one"),
-				Number:       scalar.Int32(1),
+				Name:         proto.String("field_one"),
+				Number:       proto.Int32(1),
 				Label:        descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
 				Type:         descriptorpb.FieldDescriptorProto_Type(pref.StringKind).Enum(),
-				DefaultValue: scalar.String("hello, \"world!\"\n"),
-				OneofIndex:   scalar.Int32(0),
+				DefaultValue: proto.String("hello, \"world!\"\n"),
+				OneofIndex:   proto.Int32(0),
 			}, {
-				Name:         scalar.String("field_two"),
-				JsonName:     scalar.String("Field2"),
-				Number:       scalar.Int32(2),
+				Name:         proto.String("field_two"),
+				JsonName:     proto.String("Field2"),
+				Number:       proto.Int32(2),
 				Label:        descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
 				Type:         descriptorpb.FieldDescriptorProto_Type(pref.EnumKind).Enum(),
-				DefaultValue: scalar.String("BAR"),
-				TypeName:     scalar.String(".test.E1"),
-				OneofIndex:   scalar.Int32(1),
+				DefaultValue: proto.String("BAR"),
+				TypeName:     proto.String(".test.E1"),
+				OneofIndex:   proto.Int32(1),
 			}, {
-				Name:       scalar.String("field_three"),
-				Number:     scalar.Int32(3),
+				Name:       proto.String("field_three"),
+				Number:     proto.Int32(3),
 				Label:      descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
 				Type:       descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
-				TypeName:   scalar.String(".test.C"),
-				OneofIndex: scalar.Int32(1),
+				TypeName:   proto.String(".test.C"),
+				OneofIndex: proto.Int32(1),
 			}, {
-				Name:     scalar.String("field_four"),
-				JsonName: scalar.String("Field4"),
-				Number:   scalar.Int32(4),
+				Name:     proto.String("field_four"),
+				JsonName: proto.String("Field4"),
+				Number:   proto.Int32(4),
 				Label:    descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
 				Type:     descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
-				TypeName: scalar.String(".test.B.FieldFourEntry"),
+				TypeName: proto.String(".test.B.FieldFourEntry"),
 			}, {
-				Name:    scalar.String("field_five"),
-				Number:  scalar.Int32(5),
+				Name:    proto.String("field_five"),
+				Number:  proto.Int32(5),
 				Label:   descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
 				Type:    descriptorpb.FieldDescriptorProto_Type(pref.Int32Kind).Enum(),
-				Options: &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
+				Options: &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
 			}, {
-				Name:   scalar.String("field_six"),
-				Number: scalar.Int32(6),
+				Name:   proto.String("field_six"),
+				Number: proto.Int32(6),
 				Label:  descriptorpb.FieldDescriptorProto_Label(pref.Required).Enum(),
 				Type:   descriptorpb.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
 			}},
 			OneofDecl: []*descriptorpb.OneofDescriptorProto{
 				{
-					Name: scalar.String("O1"),
+					Name: proto.String("O1"),
 					Options: &descriptorpb.OneofOptions{
 						UninterpretedOption: []*descriptorpb.UninterpretedOption{
 							{StringValue: []byte("option")},
 						},
 					},
 				},
-				{Name: scalar.String("O2")},
+				{Name: proto.String("O2")},
 			},
 			ReservedName: []string{"fizz", "buzz"},
 			ReservedRange: []*descriptorpb.DescriptorProto_ReservedRange{
-				{Start: scalar.Int32(100), End: scalar.Int32(200)},
-				{Start: scalar.Int32(300), End: scalar.Int32(301)},
+				{Start: proto.Int32(100), End: proto.Int32(200)},
+				{Start: proto.Int32(300), End: proto.Int32(301)},
 			},
 			ExtensionRange: []*descriptorpb.DescriptorProto_ExtensionRange{
-				{Start: scalar.Int32(1000), End: scalar.Int32(2000)},
-				{Start: scalar.Int32(3000), End: scalar.Int32(3001), Options: new(descriptorpb.ExtensionRangeOptions)},
+				{Start: proto.Int32(1000), End: proto.Int32(2000)},
+				{Start: proto.Int32(3000), End: proto.Int32(3001), Options: new(descriptorpb.ExtensionRangeOptions)},
 			},
 			NestedType: []*descriptorpb.DescriptorProto{{
-				Name: scalar.String("FieldFourEntry"),
+				Name: proto.String("FieldFourEntry"),
 				Field: []*descriptorpb.FieldDescriptorProto{{
-					Name:   scalar.String("key"),
-					Number: scalar.Int32(1),
+					Name:   proto.String("key"),
+					Number: proto.Int32(1),
 					Label:  descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
 					Type:   descriptorpb.FieldDescriptorProto_Type(pref.StringKind).Enum(),
 				}, {
-					Name:     scalar.String("value"),
-					Number:   scalar.Int32(2),
+					Name:     proto.String("value"),
+					Number:   proto.Int32(2),
 					Label:    descriptorpb.FieldDescriptorProto_Label(pref.Optional).Enum(),
 					Type:     descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
-					TypeName: scalar.String(".test.B"),
+					TypeName: proto.String(".test.B"),
 				}},
 				Options: &descriptorpb.MessageOptions{
-					MapEntry: scalar.Bool(true),
+					MapEntry: proto.Bool(true),
 				},
 			}},
 		}, {
-			Name: scalar.String("C"),
+			Name: proto.String("C"),
 			NestedType: []*descriptorpb.DescriptorProto{{
-				Name: scalar.String("A"),
+				Name: proto.String("A"),
 				Field: []*descriptorpb.FieldDescriptorProto{{
-					Name:         scalar.String("F"),
-					Number:       scalar.Int32(1),
+					Name:         proto.String("F"),
+					Number:       proto.Int32(1),
 					Label:        descriptorpb.FieldDescriptorProto_Label(pref.Required).Enum(),
 					Type:         descriptorpb.FieldDescriptorProto_Type(pref.BytesKind).Enum(),
-					DefaultValue: scalar.String(`dead\276\357`),
+					DefaultValue: proto.String(`dead\276\357`),
 				}},
 			}},
 			EnumType: []*descriptorpb.EnumDescriptorProto{{
-				Name: scalar.String("E1"),
+				Name: proto.String("E1"),
 				Value: []*descriptorpb.EnumValueDescriptorProto{
-					{Name: scalar.String("FOO"), Number: scalar.Int32(0)},
-					{Name: scalar.String("BAR"), Number: scalar.Int32(1)},
+					{Name: proto.String("FOO"), Number: proto.Int32(0)},
+					{Name: proto.String("BAR"), Number: proto.Int32(1)},
 				},
 			}},
 			Extension: []*descriptorpb.FieldDescriptorProto{{
-				Name:     scalar.String("X"),
-				Number:   scalar.Int32(1000),
+				Name:     proto.String("X"),
+				Number:   proto.Int32(1000),
 				Label:    descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
 				Type:     descriptorpb.FieldDescriptorProto_Type(pref.MessageKind).Enum(),
-				TypeName: scalar.String(".test.C"),
-				Extendee: scalar.String(".test.B"),
+				TypeName: proto.String(".test.C"),
+				Extendee: proto.String(".test.B"),
 			}},
 		}},
 		EnumType: []*descriptorpb.EnumDescriptorProto{{
-			Name:    scalar.String("E1"),
-			Options: &descriptorpb.EnumOptions{Deprecated: scalar.Bool(true)},
+			Name:    proto.String("E1"),
+			Options: &descriptorpb.EnumOptions{Deprecated: proto.Bool(true)},
 			Value: []*descriptorpb.EnumValueDescriptorProto{
 				{
-					Name:    scalar.String("FOO"),
-					Number:  scalar.Int32(0),
-					Options: &descriptorpb.EnumValueOptions{Deprecated: scalar.Bool(true)},
+					Name:    proto.String("FOO"),
+					Number:  proto.Int32(0),
+					Options: &descriptorpb.EnumValueOptions{Deprecated: proto.Bool(true)},
 				},
-				{Name: scalar.String("BAR"), Number: scalar.Int32(1)},
+				{Name: proto.String("BAR"), Number: proto.Int32(1)},
 			},
 			ReservedName: []string{"FIZZ", "BUZZ"},
 			ReservedRange: []*descriptorpb.EnumDescriptorProto_EnumReservedRange{
-				{Start: scalar.Int32(10), End: scalar.Int32(19)},
-				{Start: scalar.Int32(30), End: scalar.Int32(30)},
+				{Start: proto.Int32(10), End: proto.Int32(19)},
+				{Start: proto.Int32(30), End: proto.Int32(30)},
 			},
 		}},
 		Extension: []*descriptorpb.FieldDescriptorProto{{
-			Name:     scalar.String("X"),
-			Number:   scalar.Int32(1000),
+			Name:     proto.String("X"),
+			Number:   proto.Int32(1000),
 			Label:    descriptorpb.FieldDescriptorProto_Label(pref.Repeated).Enum(),
 			Type:     descriptorpb.FieldDescriptorProto_Type(pref.EnumKind).Enum(),
-			Options:  &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
-			TypeName: scalar.String(".test.E1"),
-			Extendee: scalar.String(".test.B"),
+			Options:  &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
+			TypeName: proto.String(".test.E1"),
+			Extendee: proto.String(".test.B"),
 		}},
 		Service: []*descriptorpb.ServiceDescriptorProto{{
-			Name:    scalar.String("S"),
-			Options: &descriptorpb.ServiceOptions{Deprecated: scalar.Bool(true)},
+			Name:    proto.String("S"),
+			Options: &descriptorpb.ServiceOptions{Deprecated: proto.Bool(true)},
 			Method: []*descriptorpb.MethodDescriptorProto{{
-				Name:            scalar.String("M"),
-				InputType:       scalar.String(".test.A"),
-				OutputType:      scalar.String(".test.C.A"),
-				ClientStreaming: scalar.Bool(true),
-				ServerStreaming: scalar.Bool(true),
-				Options:         &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
+				Name:            proto.String("M"),
+				InputType:       proto.String(".test.A"),
+				OutputType:      proto.String(".test.C.A"),
+				ClientStreaming: proto.Bool(true),
+				ServerStreaming: proto.Bool(true),
+				Options:         &descriptorpb.MethodOptions{Deprecated: proto.Bool(true)},
 			}},
 		}},
 	}
@@ -233,7 +232,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 		"Path":          "path/to/file.proto",
 		"Package":       pref.FullName("test"),
 		"IsPlaceholder": false,
-		"Options":       &descriptorpb.FileOptions{Deprecated: scalar.Bool(true)},
+		"Options":       &descriptorpb.FileOptions{Deprecated: proto.Bool(true)},
 		"Messages": M{
 			"Len": 3,
 			"Get:0": M{
@@ -245,7 +244,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 				"IsPlaceholder": false,
 				"IsMapEntry":    false,
 				"Options": &descriptorpb.MessageOptions{
-					Deprecated: scalar.Bool(true),
+					Deprecated: proto.Bool(true),
 				},
 				"Oneofs":          M{"Len": 0},
 				"RequiredNumbers": M{"Len": 0},
@@ -446,13 +445,13 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 			"Len": 1,
 			"Get:0": M{
 				"Name":    pref.Name("E1"),
-				"Options": &descriptorpb.EnumOptions{Deprecated: scalar.Bool(true)},
+				"Options": &descriptorpb.EnumOptions{Deprecated: proto.Bool(true)},
 				"Values": M{
 					"Len":        2,
 					"ByName:Foo": nil,
 					"ByName:FOO": M{
 						"FullName": pref.FullName("test.FOO"),
-						"Options":  &descriptorpb.EnumValueOptions{Deprecated: scalar.Bool(true)},
+						"Options":  &descriptorpb.EnumValueOptions{Deprecated: proto.Bool(true)},
 					},
 					"ByNumber:2": nil,
 					"ByNumber:1": M{"FullName": pref.FullName("test.BAR")},
@@ -492,7 +491,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 				"ContainingOneof":   nil,
 				"ContainingMessage": M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
 				"Enum":              M{"FullName": pref.FullName("test.E1"), "IsPlaceholder": false},
-				"Options":           &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
+				"Options":           &descriptorpb.FieldOptions{Packed: proto.Bool(true)},
 			},
 		},
 		"Services": M{
@@ -502,7 +501,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 				"Parent":   M{"FullName": pref.FullName("test")},
 				"Name":     pref.Name("S"),
 				"FullName": pref.FullName("test.S"),
-				"Options":  &descriptorpb.ServiceOptions{Deprecated: scalar.Bool(true)},
+				"Options":  &descriptorpb.ServiceOptions{Deprecated: proto.Bool(true)},
 				"Methods": M{
 					"Len": 1,
 					"Get:0": M{
@@ -513,7 +512,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 						"Output":            M{"FullName": pref.FullName("test.C.A"), "IsPlaceholder": false},
 						"IsStreamingClient": true,
 						"IsStreamingServer": true,
-						"Options":           &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
+						"Options":           &descriptorpb.MethodOptions{Deprecated: proto.Bool(true)},
 					},
 				},
 			},

+ 2 - 3
internal/impl/legacy_test.go

@@ -15,7 +15,6 @@ import (
 	"google.golang.org/protobuf/encoding/prototext"
 	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/internal/pragma"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	pdesc "google.golang.org/protobuf/reflect/protodesc"
 	pref "google.golang.org/protobuf/reflect/protoreflect"
@@ -375,8 +374,8 @@ func TestLegacyExtensions(t *testing.T) {
 	}
 
 	// Set some values and append to values to the lists.
-	m1a := &proto2_20180125.Message_ChildMessage{F1: scalar.String("m1a")}
-	m1b := &proto2_20180125.Message_ChildMessage{F1: scalar.String("m2b")}
+	m1a := &proto2_20180125.Message_ChildMessage{F1: proto.String("m1a")}
+	m1b := &proto2_20180125.Message_ChildMessage{F1: proto.String("m2b")}
 	m2a := &EnumMessages{EnumP2: EnumProto2(0x1b).Enum()}
 	m2b := &EnumMessages{EnumP2: EnumProto2(0x2b).Enum()}
 	setValues := map[int]interface{}{

+ 8 - 9
internal/impl/message_test.go

@@ -17,7 +17,6 @@ import (
 	cmpopts "github.com/google/go-cmp/cmp/cmpopts"
 	"google.golang.org/protobuf/encoding/prototext"
 	pimpl "google.golang.org/protobuf/internal/impl"
-	scalar "google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	pdesc "google.golang.org/protobuf/reflect/protodesc"
 	pref "google.golang.org/protobuf/reflect/protoreflect"
@@ -1071,10 +1070,10 @@ func TestEnumMessages(t *testing.T) {
 	emptyM2 := new(ScalarProto2).ProtoReflect()
 	emptyM3 := new(ScalarProto3).ProtoReflect()
 
-	wantL := pimpl.Export{}.MessageOf(&proto2_20180125.Message{OptionalFloat: scalar.Float32(math.E)})
+	wantL := pimpl.Export{}.MessageOf(&proto2_20180125.Message{OptionalFloat: proto.Float32(math.E)})
 	wantM := (&EnumMessages{EnumP2: EnumProto2(1234).Enum()}).ProtoReflect()
-	wantM2a := &ScalarProto2{Float32: scalar.Float32(math.Pi)}
-	wantM2b := &ScalarProto2{Float32: scalar.Float32(math.Phi)}
+	wantM2a := &ScalarProto2{Float32: proto.Float32(math.Pi)}
+	wantM2b := &ScalarProto2{Float32: proto.Float32(math.Phi)}
 	wantM3a := &ScalarProto3{Float32: math.Pi}
 	wantM3b := &ScalarProto3{Float32: math.Ln2}
 
@@ -1158,7 +1157,7 @@ func TestEnumMessages(t *testing.T) {
 		equalMessage{(&EnumMessages{
 			EnumP2:        EnumProto2(0xdead).Enum(),
 			EnumP3:        EnumProto3(0).Enum(),
-			MessageLegacy: &proto2_20180125.Message{OptionalFloat: scalar.Float32(math.E)},
+			MessageLegacy: &proto2_20180125.Message{OptionalFloat: proto.Float32(math.E)},
 			MessageCycle:  wantM.Interface().(*EnumMessages),
 			MessageList:   []*ScalarProto2{wantM2a, wantM2b},
 			EnumMap:       map[string]EnumProto3{"one": 1, "two": 2},
@@ -1466,12 +1465,12 @@ func TestUnsafeAssumptions(t *testing.T) {
 			// Trigger the GC after each iteration.
 			for j := 0; j < 10; j++ {
 				ms[j] = (&testpb.TestAllTypes{
-					OptionalInt32: scalar.Int32(int32(j)),
-					OptionalFloat: scalar.Float32(float32(j)),
+					OptionalInt32: proto.Int32(int32(j)),
+					OptionalFloat: proto.Float32(float32(j)),
 					RepeatedInt32: []int32{int32(j)},
 					RepeatedFloat: []float32{float32(j)},
-					DefaultInt32:  scalar.Int32(int32(j)),
-					DefaultFloat:  scalar.Float32(float32(j)),
+					DefaultInt32:  proto.Int32(int32(j)),
+					DefaultFloat:  proto.Float32(float32(j)),
 				}).ProtoReflect()
 				runtime.GC()
 			}

+ 0 - 18
internal/scalar/scalar.go

@@ -1,18 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package scalar provides wrappers for populating optional scalar fields.
-package scalar
-
-// TODO: Should this be public in the v2 API? Where should it live?
-// Would we want to do something different if Go gets generics?
-
-func Bool(v bool) *bool          { return &v }
-func Int32(v int32) *int32       { return &v }
-func Int64(v int64) *int64       { return &v }
-func Uint32(v uint32) *uint32    { return &v }
-func Uint64(v uint64) *uint64    { return &v }
-func Float32(v float32) *float32 { return &v }
-func Float64(v float64) *float64 { return &v }
-func String(v string) *string    { return &v }

+ 65 - 66
proto/decode_test.go

@@ -12,7 +12,6 @@ import (
 	protoV1 "github.com/golang/protobuf/proto"
 	"google.golang.org/protobuf/encoding/prototext"
 	"google.golang.org/protobuf/internal/encoding/pack"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	pref "google.golang.org/protobuf/reflect/protoreflect"
 
@@ -90,20 +89,20 @@ var testProtos = []testProto{
 	{
 		desc: "basic scalar types",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
-			OptionalInt32:      scalar.Int32(1001),
-			OptionalInt64:      scalar.Int64(1002),
-			OptionalUint32:     scalar.Uint32(1003),
-			OptionalUint64:     scalar.Uint64(1004),
-			OptionalSint32:     scalar.Int32(1005),
-			OptionalSint64:     scalar.Int64(1006),
-			OptionalFixed32:    scalar.Uint32(1007),
-			OptionalFixed64:    scalar.Uint64(1008),
-			OptionalSfixed32:   scalar.Int32(1009),
-			OptionalSfixed64:   scalar.Int64(1010),
-			OptionalFloat:      scalar.Float32(1011.5),
-			OptionalDouble:     scalar.Float64(1012.5),
-			OptionalBool:       scalar.Bool(true),
-			OptionalString:     scalar.String("string"),
+			OptionalInt32:      proto.Int32(1001),
+			OptionalInt64:      proto.Int64(1002),
+			OptionalUint32:     proto.Uint32(1003),
+			OptionalUint64:     proto.Uint64(1004),
+			OptionalSint32:     proto.Int32(1005),
+			OptionalSint64:     proto.Int64(1006),
+			OptionalFixed32:    proto.Uint32(1007),
+			OptionalFixed64:    proto.Uint64(1008),
+			OptionalSfixed32:   proto.Int32(1009),
+			OptionalSfixed64:   proto.Int64(1010),
+			OptionalFloat:      proto.Float32(1011.5),
+			OptionalDouble:     proto.Float64(1012.5),
+			OptionalBool:       proto.Bool(true),
+			OptionalString:     proto.String("string"),
 			OptionalBytes:      []byte("bytes"),
 			OptionalNestedEnum: testpb.TestAllTypes_BAR.Enum(),
 		}, &test3pb.TestAllTypes{
@@ -165,12 +164,12 @@ var testProtos = []testProto{
 		desc: "groups",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			Optionalgroup: &testpb.TestAllTypes_OptionalGroup{
-				A: scalar.Int32(1017),
+				A: proto.Int32(1017),
 			},
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_OptionalgroupExtension, &testpb.OptionalGroupExtension{
-				A: scalar.Int32(1017),
+				A: proto.Int32(1017),
 			}),
 		)},
 		wire: pack.Message{
@@ -183,12 +182,12 @@ var testProtos = []testProto{
 		desc: "groups (field overridden)",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			Optionalgroup: &testpb.TestAllTypes_OptionalGroup{
-				A: scalar.Int32(2),
+				A: proto.Int32(2),
 			},
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_OptionalgroupExtension, &testpb.OptionalGroupExtension{
-				A: scalar.Int32(2),
+				A: proto.Int32(2),
 			}),
 		)},
 		wire: pack.Message{
@@ -204,9 +203,9 @@ var testProtos = []testProto{
 		desc: "messages",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(42),
+				A: proto.Int32(42),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt32: scalar.Int32(43),
+					OptionalInt32: proto.Int32(43),
 				},
 			},
 		}, &test3pb.TestAllTypes{
@@ -219,9 +218,9 @@ var testProtos = []testProto{
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_OptionalNestedMessageExtension, &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(42),
+				A: proto.Int32(42),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt32: scalar.Int32(43),
+					OptionalInt32: proto.Int32(43),
 				},
 			}),
 		)},
@@ -238,9 +237,9 @@ var testProtos = []testProto{
 		desc: "messages (split across multiple tags)",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(42),
+				A: proto.Int32(42),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt32: scalar.Int32(43),
+					OptionalInt32: proto.Int32(43),
 				},
 			},
 		}, &test3pb.TestAllTypes{
@@ -253,9 +252,9 @@ var testProtos = []testProto{
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_OptionalNestedMessageExtension, &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(42),
+				A: proto.Int32(42),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt32: scalar.Int32(43),
+					OptionalInt32: proto.Int32(43),
 				},
 			}),
 		)},
@@ -274,7 +273,7 @@ var testProtos = []testProto{
 		desc: "messages (field overridden)",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(2),
+				A: proto.Int32(2),
 			},
 		}, &test3pb.TestAllTypes{
 			OptionalNestedMessage: &test3pb.TestAllTypes_NestedMessage{
@@ -283,7 +282,7 @@ var testProtos = []testProto{
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_OptionalNestedMessageExtension, &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(2),
+				A: proto.Int32(2),
 			}),
 		)},
 		wire: pack.Message{
@@ -588,9 +587,9 @@ var testProtos = []testProto{
 		desc: "repeated messages",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(1)},
+				{A: proto.Int32(1)},
 				nil,
-				{A: scalar.Int32(2)},
+				{A: proto.Int32(2)},
 			},
 		}, &test3pb.TestAllTypes{
 			RepeatedNestedMessage: []*test3pb.TestAllTypes_NestedMessage{
@@ -601,9 +600,9 @@ var testProtos = []testProto{
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_RepeatedNestedMessageExtension, []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(1)},
+				{A: proto.Int32(1)},
 				nil,
-				{A: scalar.Int32(2)},
+				{A: proto.Int32(2)},
 			}),
 		)},
 		wire: pack.Message{
@@ -620,16 +619,16 @@ var testProtos = []testProto{
 		desc: "repeated groups",
 		decodeTo: []proto.Message{&testpb.TestAllTypes{
 			Repeatedgroup: []*testpb.TestAllTypes_RepeatedGroup{
-				{A: scalar.Int32(1017)},
+				{A: proto.Int32(1017)},
 				nil,
-				{A: scalar.Int32(2017)},
+				{A: proto.Int32(2017)},
 			},
 		}, build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_RepeatedgroupExtension, []*testpb.RepeatedGroupExtension{
-				{A: scalar.Int32(1017)},
+				{A: proto.Int32(1017)},
 				nil,
-				{A: scalar.Int32(2017)},
+				{A: proto.Int32(2017)},
 			}),
 		)},
 		wire: pack.Message{
@@ -662,8 +661,8 @@ var testProtos = []testProto{
 			MapStringString:     map[string]string{"69.1.key": "69.1.val", "69.2.key": "69.2.val"},
 			MapStringBytes:      map[string][]byte{"70.1.key": []byte("70.1.val"), "70.2.key": []byte("70.2.val")},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"71.1.key": {A: scalar.Int32(1171)},
-				"71.2.key": {A: scalar.Int32(2171)},
+				"71.1.key": {A: proto.Int32(1171)},
+				"71.2.key": {A: proto.Int32(2171)},
 			},
 			MapStringNestedEnum: map[string]testpb.TestAllTypes_NestedEnum{
 				"73.1.key": testpb.TestAllTypes_FOO,
@@ -849,7 +848,7 @@ var testProtos = []testProto{
 		desc: "oneof (message)",
 		decodeTo: []proto.Message{
 			&testpb.TestAllTypes{OneofField: &testpb.TestAllTypes_OneofNestedMessage{
-				&testpb.TestAllTypes_NestedMessage{A: scalar.Int32(1112)},
+				&testpb.TestAllTypes_NestedMessage{A: proto.Int32(1112)},
 			}}, &test3pb.TestAllTypes{OneofField: &test3pb.TestAllTypes_OneofNestedMessage{
 				&test3pb.TestAllTypes_NestedMessage{A: 1112},
 			}},
@@ -877,7 +876,7 @@ var testProtos = []testProto{
 				&testpb.TestAllTypes_NestedMessage{
 					A: scalar.Int32(1),
 					Corecursive: &testpb.TestAllTypes{
-						OptionalInt32: scalar.Int32(43),
+						OptionalInt32: proto.Int32(43),
 					},
 				},
 			}}, &test3pb.TestAllTypes{OneofField: &test3pb.TestAllTypes_OneofNestedMessage{
@@ -1042,7 +1041,7 @@ var testProtos = []testProto{
 	{
 		desc: "required field set",
 		decodeTo: []proto.Message{&testpb.TestRequired{
-			RequiredField: scalar.Int32(1),
+			RequiredField: proto.Int32(1),
 		}},
 		wire: pack.Message{
 			pack.Tag{1, pack.VarintType}, pack.Varint(1),
@@ -1062,7 +1061,7 @@ var testProtos = []testProto{
 		desc: "required field in optional message set",
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			OptionalMessage: &testpb.TestRequired{
-				RequiredField: scalar.Int32(1),
+				RequiredField: proto.Int32(1),
 			},
 		}},
 		wire: pack.Message{
@@ -1075,7 +1074,7 @@ var testProtos = []testProto{
 		desc: "required field in optional message set (split across multiple tags)",
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			OptionalMessage: &testpb.TestRequired{
-				RequiredField: scalar.Int32(1),
+				RequiredField: proto.Int32(1),
 			},
 		}},
 		wire: pack.Message{
@@ -1090,7 +1089,7 @@ var testProtos = []testProto{
 		partial: true,
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			RepeatedMessage: []*testpb.TestRequired{
-				{RequiredField: scalar.Int32(1)},
+				{RequiredField: proto.Int32(1)},
 				{},
 			},
 		}},
@@ -1105,8 +1104,8 @@ var testProtos = []testProto{
 		desc: "required field in repeated message set",
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			RepeatedMessage: []*testpb.TestRequired{
-				{RequiredField: scalar.Int32(1)},
-				{RequiredField: scalar.Int32(2)},
+				{RequiredField: proto.Int32(1)},
+				{RequiredField: proto.Int32(2)},
 			},
 		}},
 		wire: pack.Message{
@@ -1123,7 +1122,7 @@ var testProtos = []testProto{
 		partial: true,
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			MapMessage: map[int32]*testpb.TestRequired{
-				1: {RequiredField: scalar.Int32(1)},
+				1: {RequiredField: proto.Int32(1)},
 				2: {},
 			},
 		}},
@@ -1144,8 +1143,8 @@ var testProtos = []testProto{
 		desc: "required field in map message set",
 		decodeTo: []proto.Message{&testpb.TestRequiredForeign{
 			MapMessage: map[int32]*testpb.TestRequired{
-				1: {RequiredField: scalar.Int32(1)},
-				2: {RequiredField: scalar.Int32(2)},
+				1: {RequiredField: proto.Int32(1)},
+				2: {RequiredField: proto.Int32(2)},
 			},
 		}},
 		wire: pack.Message{
@@ -1178,7 +1177,7 @@ var testProtos = []testProto{
 		desc: "required field in optional group set",
 		decodeTo: []proto.Message{&testpb.TestRequiredGroupFields{
 			Optionalgroup: &testpb.TestRequiredGroupFields_OptionalGroup{
-				A: scalar.Int32(1),
+				A: proto.Int32(1),
 			},
 		}},
 		wire: pack.Message{
@@ -1192,7 +1191,7 @@ var testProtos = []testProto{
 		partial: true,
 		decodeTo: []proto.Message{&testpb.TestRequiredGroupFields{
 			Repeatedgroup: []*testpb.TestRequiredGroupFields_RepeatedGroup{
-				{A: scalar.Int32(1)},
+				{A: proto.Int32(1)},
 				{},
 			},
 		}},
@@ -1208,8 +1207,8 @@ var testProtos = []testProto{
 		desc: "required field in repeated group set",
 		decodeTo: []proto.Message{&testpb.TestRequiredGroupFields{
 			Repeatedgroup: []*testpb.TestRequiredGroupFields_RepeatedGroup{
-				{A: scalar.Int32(1)},
-				{A: scalar.Int32(2)},
+				{A: proto.Int32(1)},
+				{A: proto.Int32(2)},
 			},
 		}},
 		wire: pack.Message{
@@ -1236,7 +1235,7 @@ var testProtos = []testProto{
 		decodeTo: []proto.Message{
 			&testpb.TestRequiredForeign{OneofField: &testpb.TestRequiredForeign_OneofMessage{
 				&testpb.TestRequired{
-					RequiredField: scalar.Int32(1),
+					RequiredField: proto.Int32(1),
 				},
 			}},
 		},
@@ -1260,7 +1259,7 @@ var testProtos = []testProto{
 		decodeTo: []proto.Message{build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_TestRequired_Single, &testpb.TestRequired{
-				RequiredField: scalar.Int32(1),
+				RequiredField: proto.Int32(1),
 			}),
 		)},
 		wire: pack.Message{
@@ -1275,7 +1274,7 @@ var testProtos = []testProto{
 		decodeTo: []proto.Message{build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_TestRequired_Multi, []*testpb.TestRequired{
-				{RequiredField: scalar.Int32(1)},
+				{RequiredField: proto.Int32(1)},
 				{},
 			}),
 		)},
@@ -1291,8 +1290,8 @@ var testProtos = []testProto{
 		decodeTo: []proto.Message{build(
 			&testpb.TestAllExtensions{},
 			extend(testpb.E_TestRequired_Multi, []*testpb.TestRequired{
-				{RequiredField: scalar.Int32(1)},
-				{RequiredField: scalar.Int32(2)},
+				{RequiredField: proto.Int32(1)},
+				{RequiredField: proto.Int32(2)},
 			}),
 		)},
 		wire: pack.Message{
@@ -1318,26 +1317,26 @@ var testProtos = []testProto{
 		decodeTo: []proto.Message{
 			&legacypb.Legacy{
 				F1: &legacy1pb.Message{
-					OptionalInt32:     scalar.Int32(1),
+					OptionalInt32:     proto.Int32(1),
 					OptionalChildEnum: legacy1pb.Message_ALPHA.Enum(),
 					OptionalChildMessage: &legacy1pb.Message_ChildMessage{
-						F1: scalar.String("x"),
+						F1: proto.String("x"),
 					},
 					Optionalgroup: &legacy1pb.Message_OptionalGroup{
-						F1: scalar.String("x"),
+						F1: proto.String("x"),
 					},
 					RepeatedChildMessage: []*legacy1pb.Message_ChildMessage{
-						{F1: scalar.String("x")},
+						{F1: proto.String("x")},
 					},
 					Repeatedgroup: []*legacy1pb.Message_RepeatedGroup{
-						{F1: scalar.String("x")},
+						{F1: proto.String("x")},
 					},
 					MapBoolChildMessage: map[bool]*legacy1pb.Message_ChildMessage{
-						true: {F1: scalar.String("x")},
+						true: {F1: proto.String("x")},
 					},
 					OneofUnion: &legacy1pb.Message_OneofChildMessage{
 						&legacy1pb.Message_ChildMessage{
-							F1: scalar.String("x"),
+							F1: proto.String("x"),
 						},
 					},
 				},

+ 73 - 74
proto/equal_test.go

@@ -8,7 +8,6 @@ import (
 	"testing"
 
 	"google.golang.org/protobuf/internal/encoding/pack"
-	"google.golang.org/protobuf/internal/scalar"
 	testpb "google.golang.org/protobuf/internal/testprotos/test"
 	test3pb "google.golang.org/protobuf/internal/testprotos/test3"
 	"google.golang.org/protobuf/proto"
@@ -28,60 +27,60 @@ func TestEqual(t *testing.T) {
 var inequalities = []struct{ a, b proto.Message }{
 	// Scalar values.
 	{
-		&testpb.TestAllTypes{OptionalInt32: scalar.Int32(1)},
-		&testpb.TestAllTypes{OptionalInt32: scalar.Int32(2)},
+		&testpb.TestAllTypes{OptionalInt32: proto.Int32(1)},
+		&testpb.TestAllTypes{OptionalInt32: proto.Int32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalInt64: scalar.Int64(1)},
-		&testpb.TestAllTypes{OptionalInt64: scalar.Int64(2)},
+		&testpb.TestAllTypes{OptionalInt64: proto.Int64(1)},
+		&testpb.TestAllTypes{OptionalInt64: proto.Int64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalUint32: scalar.Uint32(1)},
-		&testpb.TestAllTypes{OptionalUint32: scalar.Uint32(2)},
+		&testpb.TestAllTypes{OptionalUint32: proto.Uint32(1)},
+		&testpb.TestAllTypes{OptionalUint32: proto.Uint32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalUint64: scalar.Uint64(1)},
-		&testpb.TestAllTypes{OptionalUint64: scalar.Uint64(2)},
+		&testpb.TestAllTypes{OptionalUint64: proto.Uint64(1)},
+		&testpb.TestAllTypes{OptionalUint64: proto.Uint64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalSint32: scalar.Int32(1)},
-		&testpb.TestAllTypes{OptionalSint32: scalar.Int32(2)},
+		&testpb.TestAllTypes{OptionalSint32: proto.Int32(1)},
+		&testpb.TestAllTypes{OptionalSint32: proto.Int32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalSint64: scalar.Int64(1)},
-		&testpb.TestAllTypes{OptionalSint64: scalar.Int64(2)},
+		&testpb.TestAllTypes{OptionalSint64: proto.Int64(1)},
+		&testpb.TestAllTypes{OptionalSint64: proto.Int64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalFixed32: scalar.Uint32(1)},
-		&testpb.TestAllTypes{OptionalFixed32: scalar.Uint32(2)},
+		&testpb.TestAllTypes{OptionalFixed32: proto.Uint32(1)},
+		&testpb.TestAllTypes{OptionalFixed32: proto.Uint32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalFixed64: scalar.Uint64(1)},
-		&testpb.TestAllTypes{OptionalFixed64: scalar.Uint64(2)},
+		&testpb.TestAllTypes{OptionalFixed64: proto.Uint64(1)},
+		&testpb.TestAllTypes{OptionalFixed64: proto.Uint64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalSfixed32: scalar.Int32(1)},
-		&testpb.TestAllTypes{OptionalSfixed32: scalar.Int32(2)},
+		&testpb.TestAllTypes{OptionalSfixed32: proto.Int32(1)},
+		&testpb.TestAllTypes{OptionalSfixed32: proto.Int32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalSfixed64: scalar.Int64(1)},
-		&testpb.TestAllTypes{OptionalSfixed64: scalar.Int64(2)},
+		&testpb.TestAllTypes{OptionalSfixed64: proto.Int64(1)},
+		&testpb.TestAllTypes{OptionalSfixed64: proto.Int64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalFloat: scalar.Float32(1)},
-		&testpb.TestAllTypes{OptionalFloat: scalar.Float32(2)},
+		&testpb.TestAllTypes{OptionalFloat: proto.Float32(1)},
+		&testpb.TestAllTypes{OptionalFloat: proto.Float32(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalDouble: scalar.Float64(1)},
-		&testpb.TestAllTypes{OptionalDouble: scalar.Float64(2)},
+		&testpb.TestAllTypes{OptionalDouble: proto.Float64(1)},
+		&testpb.TestAllTypes{OptionalDouble: proto.Float64(2)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalBool: scalar.Bool(true)},
-		&testpb.TestAllTypes{OptionalBool: scalar.Bool(false)},
+		&testpb.TestAllTypes{OptionalBool: proto.Bool(true)},
+		&testpb.TestAllTypes{OptionalBool: proto.Bool(false)},
 	},
 	{
-		&testpb.TestAllTypes{OptionalString: scalar.String("a")},
-		&testpb.TestAllTypes{OptionalString: scalar.String("b")},
+		&testpb.TestAllTypes{OptionalString: proto.String("a")},
+		&testpb.TestAllTypes{OptionalString: proto.String("b")},
 	},
 	{
 		&testpb.TestAllTypes{OptionalBytes: []byte("a")},
@@ -94,59 +93,59 @@ var inequalities = []struct{ a, b proto.Message }{
 	// Proto2 presence.
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalInt32: scalar.Int32(0)},
+		&testpb.TestAllTypes{OptionalInt32: proto.Int32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalInt64: scalar.Int64(0)},
+		&testpb.TestAllTypes{OptionalInt64: proto.Int64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalUint32: scalar.Uint32(0)},
+		&testpb.TestAllTypes{OptionalUint32: proto.Uint32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalUint64: scalar.Uint64(0)},
+		&testpb.TestAllTypes{OptionalUint64: proto.Uint64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalSint32: scalar.Int32(0)},
+		&testpb.TestAllTypes{OptionalSint32: proto.Int32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalSint64: scalar.Int64(0)},
+		&testpb.TestAllTypes{OptionalSint64: proto.Int64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalFixed32: scalar.Uint32(0)},
+		&testpb.TestAllTypes{OptionalFixed32: proto.Uint32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalFixed64: scalar.Uint64(0)},
+		&testpb.TestAllTypes{OptionalFixed64: proto.Uint64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalSfixed32: scalar.Int32(0)},
+		&testpb.TestAllTypes{OptionalSfixed32: proto.Int32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalSfixed64: scalar.Int64(0)},
+		&testpb.TestAllTypes{OptionalSfixed64: proto.Int64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalFloat: scalar.Float32(0)},
+		&testpb.TestAllTypes{OptionalFloat: proto.Float32(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalDouble: scalar.Float64(0)},
+		&testpb.TestAllTypes{OptionalDouble: proto.Float64(0)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalBool: scalar.Bool(false)},
+		&testpb.TestAllTypes{OptionalBool: proto.Bool(false)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{OptionalString: scalar.String("")},
+		&testpb.TestAllTypes{OptionalString: proto.String("")},
 	},
 	{
 		&testpb.TestAllTypes{},
@@ -159,10 +158,10 @@ var inequalities = []struct{ a, b proto.Message }{
 	// Groups.
 	{
 		&testpb.TestAllTypes{Optionalgroup: &testpb.TestAllTypes_OptionalGroup{
-			A: scalar.Int32(1),
+			A: proto.Int32(1),
 		}},
 		&testpb.TestAllTypes{Optionalgroup: &testpb.TestAllTypes_OptionalGroup{
-			A: scalar.Int32(2),
+			A: proto.Int32(2),
 		}},
 	},
 	{
@@ -172,10 +171,10 @@ var inequalities = []struct{ a, b proto.Message }{
 	// Messages.
 	{
 		&testpb.TestAllTypes{OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-			A: scalar.Int32(1),
+			A: proto.Int32(1),
 		}},
 		&testpb.TestAllTypes{OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-			A: scalar.Int32(2),
+			A: proto.Int32(2),
 		}},
 	},
 	{
@@ -257,22 +256,22 @@ var inequalities = []struct{ a, b proto.Message }{
 	},
 	{
 		&testpb.TestAllTypes{Repeatedgroup: []*testpb.TestAllTypes_RepeatedGroup{
-			{A: scalar.Int32(1)},
-			{A: scalar.Int32(2)},
+			{A: proto.Int32(1)},
+			{A: proto.Int32(2)},
 		}},
 		&testpb.TestAllTypes{Repeatedgroup: []*testpb.TestAllTypes_RepeatedGroup{
-			{A: scalar.Int32(1)},
-			{A: scalar.Int32(3)},
+			{A: proto.Int32(1)},
+			{A: proto.Int32(3)},
 		}},
 	},
 	{
 		&testpb.TestAllTypes{RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-			{A: scalar.Int32(1)},
-			{A: scalar.Int32(2)},
+			{A: proto.Int32(1)},
+			{A: proto.Int32(2)},
 		}},
 		&testpb.TestAllTypes{RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-			{A: scalar.Int32(1)},
-			{A: scalar.Int32(3)},
+			{A: proto.Int32(1)},
+			{A: proto.Int32(3)},
 		}},
 	},
 	// Maps: various configurations.
@@ -351,12 +350,12 @@ var inequalities = []struct{ a, b proto.Message }{
 	},
 	{
 		&testpb.TestAllTypes{MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-			"a": {A: scalar.Int32(1)},
-			"b": {A: scalar.Int32(2)},
+			"a": {A: proto.Int32(1)},
+			"b": {A: proto.Int32(2)},
 		}},
 		&testpb.TestAllTypes{MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-			"a": {A: scalar.Int32(1)},
-			"b": {A: scalar.Int32(3)},
+			"a": {A: proto.Int32(1)},
+			"b": {A: proto.Int32(3)},
 		}},
 	},
 	{
@@ -407,64 +406,64 @@ var inequalities = []struct{ a, b proto.Message }{
 	},
 	// Proto2 default values are not considered by Equal, so the following are still unequal.
 	{
-		&testpb.TestAllTypes{DefaultInt32: scalar.Int32(81)},
+		&testpb.TestAllTypes{DefaultInt32: proto.Int32(81)},
 		&testpb.TestAllTypes{},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultInt32: scalar.Int32(81)},
+		&testpb.TestAllTypes{DefaultInt32: proto.Int32(81)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultInt64: scalar.Int64(82)},
+		&testpb.TestAllTypes{DefaultInt64: proto.Int64(82)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultUint32: scalar.Uint32(83)},
+		&testpb.TestAllTypes{DefaultUint32: proto.Uint32(83)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultUint64: scalar.Uint64(84)},
+		&testpb.TestAllTypes{DefaultUint64: proto.Uint64(84)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultSint32: scalar.Int32(-85)},
+		&testpb.TestAllTypes{DefaultSint32: proto.Int32(-85)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultSint64: scalar.Int64(86)},
+		&testpb.TestAllTypes{DefaultSint64: proto.Int64(86)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultFixed32: scalar.Uint32(87)},
+		&testpb.TestAllTypes{DefaultFixed32: proto.Uint32(87)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultFixed64: scalar.Uint64(88)},
+		&testpb.TestAllTypes{DefaultFixed64: proto.Uint64(88)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultSfixed32: scalar.Int32(89)},
+		&testpb.TestAllTypes{DefaultSfixed32: proto.Int32(89)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultSfixed64: scalar.Int64(-90)},
+		&testpb.TestAllTypes{DefaultSfixed64: proto.Int64(-90)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultFloat: scalar.Float32(91.5)},
+		&testpb.TestAllTypes{DefaultFloat: proto.Float32(91.5)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultDouble: scalar.Float64(92e3)},
+		&testpb.TestAllTypes{DefaultDouble: proto.Float64(92e3)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultBool: scalar.Bool(true)},
+		&testpb.TestAllTypes{DefaultBool: proto.Bool(true)},
 	},
 	{
 		&testpb.TestAllTypes{},
-		&testpb.TestAllTypes{DefaultString: scalar.String("hello")},
+		&testpb.TestAllTypes{DefaultString: proto.String("hello")},
 	},
 	{
 		&testpb.TestAllTypes{},

+ 1 - 2
proto/isinit_test.go

@@ -8,7 +8,6 @@ import (
 	"fmt"
 	"testing"
 
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 
 	testpb "google.golang.org/protobuf/internal/testprotos/test"
@@ -32,7 +31,7 @@ func TestIsInitializedErrors(t *testing.T) {
 		{
 			&testpb.TestRequiredForeign{
 				RepeatedMessage: []*testpb.TestRequired{
-					{RequiredField: scalar.Int32(1)},
+					{RequiredField: proto.Int32(1)},
 					{},
 				},
 			},

+ 44 - 45
proto/merge_test.go

@@ -8,7 +8,6 @@ import (
 	"testing"
 
 	"google.golang.org/protobuf/internal/encoding/pack"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 
 	testpb "google.golang.org/protobuf/internal/testprotos/test"
@@ -36,52 +35,52 @@ func TestMerge(t *testing.T) {
 		desc: "clone a large message",
 		dst:  new(testpb.TestAllTypes),
 		src: &testpb.TestAllTypes{
-			OptionalInt64:      scalar.Int64(0),
+			OptionalInt64:      proto.Int64(0),
 			OptionalNestedEnum: testpb.TestAllTypes_NestedEnum(1).Enum(),
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(100),
+				A: proto.Int32(100),
 			},
 			RepeatedSfixed32: []int32{1, 2, 3},
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(200)},
-				{A: scalar.Int32(300)},
+				{A: proto.Int32(200)},
+				{A: proto.Int32(300)},
 			},
 			MapStringNestedEnum: map[string]testpb.TestAllTypes_NestedEnum{
 				"fizz": 400,
 				"buzz": 500,
 			},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"foo": {A: scalar.Int32(600)},
-				"bar": {A: scalar.Int32(700)},
+				"foo": {A: proto.Int32(600)},
+				"bar": {A: proto.Int32(700)},
 			},
 			OneofField: &testpb.TestAllTypes_OneofNestedMessage{
 				&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(800),
+					A: proto.Int32(800),
 				},
 			},
 		},
 		want: &testpb.TestAllTypes{
-			OptionalInt64:      scalar.Int64(0),
+			OptionalInt64:      proto.Int64(0),
 			OptionalNestedEnum: testpb.TestAllTypes_NestedEnum(1).Enum(),
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(100),
+				A: proto.Int32(100),
 			},
 			RepeatedSfixed32: []int32{1, 2, 3},
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(200)},
-				{A: scalar.Int32(300)},
+				{A: proto.Int32(200)},
+				{A: proto.Int32(300)},
 			},
 			MapStringNestedEnum: map[string]testpb.TestAllTypes_NestedEnum{
 				"fizz": 400,
 				"buzz": 500,
 			},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"foo": {A: scalar.Int32(600)},
-				"bar": {A: scalar.Int32(700)},
+				"foo": {A: proto.Int32(600)},
+				"bar": {A: proto.Int32(700)},
 			},
 			OneofField: &testpb.TestAllTypes_OneofNestedMessage{
 				&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(800),
+					A: proto.Int32(800),
 				},
 			},
 		},
@@ -122,31 +121,31 @@ func TestMerge(t *testing.T) {
 	}, {
 		desc: "merge singular fields",
 		dst: &testpb.TestAllTypes{
-			OptionalInt32:      scalar.Int32(1),
-			OptionalInt64:      scalar.Int64(1),
+			OptionalInt32:      proto.Int32(1),
+			OptionalInt64:      proto.Int64(1),
 			OptionalNestedEnum: testpb.TestAllTypes_NestedEnum(10).Enum(),
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(100),
+				A: proto.Int32(100),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt64: scalar.Int64(1000),
+					OptionalInt64: proto.Int64(1000),
 				},
 			},
 		},
 		src: &testpb.TestAllTypes{
-			OptionalInt64:      scalar.Int64(2),
+			OptionalInt64:      proto.Int64(2),
 			OptionalNestedEnum: testpb.TestAllTypes_NestedEnum(20).Enum(),
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(200),
+				A: proto.Int32(200),
 			},
 		},
 		want: &testpb.TestAllTypes{
-			OptionalInt32:      scalar.Int32(1),
-			OptionalInt64:      scalar.Int64(2),
+			OptionalInt32:      proto.Int32(1),
+			OptionalInt64:      proto.Int64(2),
 			OptionalNestedEnum: testpb.TestAllTypes_NestedEnum(20).Enum(),
 			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{
-				A: scalar.Int32(200),
+				A: proto.Int32(200),
 				Corecursive: &testpb.TestAllTypes{
-					OptionalInt64: scalar.Int64(1000),
+					OptionalInt64: proto.Int64(1000),
 				},
 			},
 		},
@@ -161,24 +160,24 @@ func TestMerge(t *testing.T) {
 		dst: &testpb.TestAllTypes{
 			RepeatedSfixed32: []int32{1, 2, 3},
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(100)},
-				{A: scalar.Int32(200)},
+				{A: proto.Int32(100)},
+				{A: proto.Int32(200)},
 			},
 		},
 		src: &testpb.TestAllTypes{
 			RepeatedSfixed32: []int32{4, 5, 6},
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(300)},
-				{A: scalar.Int32(400)},
+				{A: proto.Int32(300)},
+				{A: proto.Int32(400)},
 			},
 		},
 		want: &testpb.TestAllTypes{
 			RepeatedSfixed32: []int32{1, 2, 3, 4, 5, 6},
 			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
-				{A: scalar.Int32(100)},
-				{A: scalar.Int32(200)},
-				{A: scalar.Int32(300)},
-				{A: scalar.Int32(400)},
+				{A: proto.Int32(100)},
+				{A: proto.Int32(200)},
+				{A: proto.Int32(300)},
+				{A: proto.Int32(400)},
 			},
 		},
 		mutator: func(mi proto.Message) {
@@ -195,7 +194,7 @@ func TestMerge(t *testing.T) {
 				"guzz": 300,
 			},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"foo": {A: scalar.Int32(400)},
+				"foo": {A: proto.Int32(400)},
 			},
 		},
 		src: &testpb.TestAllTypes{
@@ -204,7 +203,7 @@ func TestMerge(t *testing.T) {
 				"buzz": 2000,
 			},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"foo": {A: scalar.Int32(3000)},
+				"foo": {A: proto.Int32(3000)},
 				"bar": {},
 			},
 		},
@@ -215,21 +214,21 @@ func TestMerge(t *testing.T) {
 				"guzz": 300,
 			},
 			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
-				"foo": {A: scalar.Int32(3000)},
+				"foo": {A: proto.Int32(3000)},
 				"bar": {},
 			},
 		},
 		mutator: func(mi proto.Message) {
 			m := mi.(*testpb.TestAllTypes)
 			delete(m.MapStringNestedEnum, "fizz")
-			m.MapStringNestedMessage["bar"].A = scalar.Int32(1)
+			m.MapStringNestedMessage["bar"].A = proto.Int32(1)
 		},
 	}, {
 		desc: "merge oneof message fields",
 		dst: &testpb.TestAllTypes{
 			OneofField: &testpb.TestAllTypes_OneofNestedMessage{
 				&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(100),
+					A: proto.Int32(100),
 				},
 			},
 		},
@@ -237,7 +236,7 @@ func TestMerge(t *testing.T) {
 			OneofField: &testpb.TestAllTypes_OneofNestedMessage{
 				&testpb.TestAllTypes_NestedMessage{
 					Corecursive: &testpb.TestAllTypes{
-						OptionalInt64: scalar.Int64(1000),
+						OptionalInt64: proto.Int64(1000),
 					},
 				},
 			},
@@ -245,9 +244,9 @@ func TestMerge(t *testing.T) {
 		want: &testpb.TestAllTypes{
 			OneofField: &testpb.TestAllTypes_OneofNestedMessage{
 				&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(100),
+					A: proto.Int32(100),
 					Corecursive: &testpb.TestAllTypes{
-						OptionalInt64: scalar.Int64(1000),
+						OptionalInt64: proto.Int64(1000),
 					},
 				},
 			},
@@ -282,7 +281,7 @@ func TestMerge(t *testing.T) {
 			m.ProtoReflect().Set(
 				testpb.E_OptionalNestedMessageExtension.Type,
 				testpb.E_OptionalNestedMessageExtension.Type.ValueOf(&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(50),
+					A: proto.Int32(50),
 				}),
 			)
 			m.ProtoReflect().Set(
@@ -301,7 +300,7 @@ func TestMerge(t *testing.T) {
 				testpb.E_OptionalNestedMessageExtension.Type,
 				testpb.E_OptionalNestedMessageExtension.Type.ValueOf(&testpb.TestAllTypes_NestedMessage{
 					Corecursive: &testpb.TestAllTypes{
-						OptionalInt64: scalar.Int64(1000),
+						OptionalInt64: proto.Int64(1000),
 					},
 				}),
 			)
@@ -324,9 +323,9 @@ func TestMerge(t *testing.T) {
 			m.ProtoReflect().Set(
 				testpb.E_OptionalNestedMessageExtension.Type,
 				testpb.E_OptionalNestedMessageExtension.Type.ValueOf(&testpb.TestAllTypes_NestedMessage{
-					A: scalar.Int32(50),
+					A: proto.Int32(50),
 					Corecursive: &testpb.TestAllTypes{
-						OptionalInt64: scalar.Int64(1000),
+						OptionalInt64: proto.Int64(1000),
 					},
 				}),
 			)

+ 1 - 2
proto/reset_test.go

@@ -7,7 +7,6 @@ package proto_test
 import (
 	"testing"
 
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 
 	testpb "google.golang.org/protobuf/internal/testprotos/test"
@@ -15,7 +14,7 @@ import (
 
 func TestReset(t *testing.T) {
 	m := &testpb.TestAllTypes{
-		OptionalSfixed64:       scalar.Int64(5),
+		OptionalSfixed64:       proto.Int64(5),
 		RepeatedInt32:          []int32{},
 		RepeatedFloat:          []float32{1.234, 5.678},
 		MapFixed64Fixed64:      map[uint64]uint64{5: 7},

+ 29 - 0
proto/wrappers.go

@@ -0,0 +1,29 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package proto
+
+// Bool stores v in a new bool value and returns a pointer to it.
+func Bool(v bool) *bool { return &v }
+
+// Int32 stores v in a new int32 value and returns a pointer to it.
+func Int32(v int32) *int32 { return &v }
+
+// Int64 stores v in a new int64 value and returns a pointer to it.
+func Int64(v int64) *int64 { return &v }
+
+// Float32 stores v in a new float32 value and returns a pointer to it.
+func Float32(v float32) *float32 { return &v }
+
+// Float64 stores v in a new float64 value and returns a pointer to it.
+func Float64(v float64) *float64 { return &v }
+
+// Uint32 stores v in a new uint32 value and returns a pointer to it.
+func Uint32(v uint32) *uint32 { return &v }
+
+// Uint64 stores v in a new uint64 value and returns a pointer to it.
+func Uint64(v uint64) *uint64 { return &v }
+
+// String stores v in a new string value and returns a pointer to it.
+func String(v string) *string { return &v }

+ 25 - 26
reflect/protodesc/proto.go

@@ -10,7 +10,6 @@ import (
 	"strings"
 
 	"google.golang.org/protobuf/internal/encoding/defval"
-	"google.golang.org/protobuf/internal/scalar"
 	"google.golang.org/protobuf/proto"
 	"google.golang.org/protobuf/reflect/protoreflect"
 
@@ -21,8 +20,8 @@ import (
 // google.protobuf.FileDescriptorProto message.
 func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto {
 	p := &descriptorpb.FileDescriptorProto{
-		Name:    scalar.String(file.Path()),
-		Package: scalar.String(string(file.Package())),
+		Name:    proto.String(file.Path()),
+		Package: proto.String(string(file.Package())),
 		Options: clone(file.Options()).(*descriptorpb.FileOptions),
 	}
 	for i, imports := 0, file.Imports(); i < imports.Len(); i++ {
@@ -48,7 +47,7 @@ func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileD
 		p.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i)))
 	}
 	if syntax := file.Syntax(); syntax != protoreflect.Proto2 {
-		p.Syntax = scalar.String(file.Syntax().String())
+		p.Syntax = proto.String(file.Syntax().String())
 	}
 	return p
 }
@@ -57,7 +56,7 @@ func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileD
 // google.protobuf.DescriptorProto message.
 func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto {
 	p := &descriptorpb.DescriptorProto{
-		Name:    scalar.String(string(message.Name())),
+		Name:    proto.String(string(message.Name())),
 		Options: clone(message.Options()).(*descriptorpb.MessageOptions),
 	}
 	for i, fields := 0, message.Fields(); i < fields.Len(); i++ {
@@ -75,8 +74,8 @@ func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.Des
 	for i, xranges := 0, message.ExtensionRanges(); i < xranges.Len(); i++ {
 		xrange := xranges.Get(i)
 		p.ExtensionRange = append(p.ExtensionRange, &descriptorpb.DescriptorProto_ExtensionRange{
-			Start:   scalar.Int32(int32(xrange[0])),
-			End:     scalar.Int32(int32(xrange[1])),
+			Start:   proto.Int32(int32(xrange[0])),
+			End:     proto.Int32(int32(xrange[1])),
 			Options: clone(message.ExtensionRangeOptions(i)).(*descriptorpb.ExtensionRangeOptions),
 		})
 	}
@@ -86,8 +85,8 @@ func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.Des
 	for i, ranges := 0, message.ReservedRanges(); i < ranges.Len(); i++ {
 		rrange := ranges.Get(i)
 		p.ReservedRange = append(p.ReservedRange, &descriptorpb.DescriptorProto_ReservedRange{
-			Start: scalar.Int32(int32(rrange[0])),
-			End:   scalar.Int32(int32(rrange[1])),
+			Start: proto.Int32(int32(rrange[0])),
+			End:   proto.Int32(int32(rrange[1])),
 		})
 	}
 	for i, names := 0, message.ReservedNames(); i < names.Len(); i++ {
@@ -100,8 +99,8 @@ func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.Des
 // google.protobuf.FieldDescriptorProto message.
 func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto {
 	p := &descriptorpb.FieldDescriptorProto{
-		Name:    scalar.String(string(field.Name())),
-		Number:  scalar.Int32(int32(field.Number())),
+		Name:    proto.String(string(field.Name())),
+		Number:  proto.Int32(int32(field.Number())),
 		Label:   descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(),
 		Options: clone(field.Options()).(*descriptorpb.FieldOptions),
 	}
@@ -118,7 +117,7 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
 		p.TypeName = fullNameOf(field.Message())
 	}
 	if field.HasJSONName() {
-		p.JsonName = scalar.String(field.JSONName())
+		p.JsonName = proto.String(field.JSONName())
 	}
 	if field.HasDefault() {
 		def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor)
@@ -127,10 +126,10 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
 		} else if err != nil {
 			panic(fmt.Sprintf("%v: %v", field.FullName(), err))
 		}
-		p.DefaultValue = scalar.String(def)
+		p.DefaultValue = proto.String(def)
 	}
 	if oneof := field.ContainingOneof(); oneof != nil {
-		p.OneofIndex = scalar.Int32(int32(oneof.Index()))
+		p.OneofIndex = proto.Int32(int32(oneof.Index()))
 	}
 	return p
 }
@@ -139,7 +138,7 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
 // google.protobuf.OneofDescriptorProto message.
 func ToOneofDescriptorProto(oneof protoreflect.OneofDescriptor) *descriptorpb.OneofDescriptorProto {
 	return &descriptorpb.OneofDescriptorProto{
-		Name:    scalar.String(string(oneof.Name())),
+		Name:    proto.String(string(oneof.Name())),
 		Options: clone(oneof.Options()).(*descriptorpb.OneofOptions),
 	}
 }
@@ -148,7 +147,7 @@ func ToOneofDescriptorProto(oneof protoreflect.OneofDescriptor) *descriptorpb.On
 // google.protobuf.EnumDescriptorProto message.
 func ToEnumDescriptorProto(enum protoreflect.EnumDescriptor) *descriptorpb.EnumDescriptorProto {
 	p := &descriptorpb.EnumDescriptorProto{
-		Name:    scalar.String(string(enum.Name())),
+		Name:    proto.String(string(enum.Name())),
 		Options: clone(enum.Options()).(*descriptorpb.EnumOptions),
 	}
 	for i, values := 0, enum.Values(); i < values.Len(); i++ {
@@ -157,8 +156,8 @@ func ToEnumDescriptorProto(enum protoreflect.EnumDescriptor) *descriptorpb.EnumD
 	for i, ranges := 0, enum.ReservedRanges(); i < ranges.Len(); i++ {
 		rrange := ranges.Get(i)
 		p.ReservedRange = append(p.ReservedRange, &descriptorpb.EnumDescriptorProto_EnumReservedRange{
-			Start: scalar.Int32(int32(rrange[0])),
-			End:   scalar.Int32(int32(rrange[1])),
+			Start: proto.Int32(int32(rrange[0])),
+			End:   proto.Int32(int32(rrange[1])),
 		})
 	}
 	for i, names := 0, enum.ReservedNames(); i < names.Len(); i++ {
@@ -171,8 +170,8 @@ func ToEnumDescriptorProto(enum protoreflect.EnumDescriptor) *descriptorpb.EnumD
 // google.protobuf.EnumValueDescriptorProto message.
 func ToEnumValueDescriptorProto(value protoreflect.EnumValueDescriptor) *descriptorpb.EnumValueDescriptorProto {
 	return &descriptorpb.EnumValueDescriptorProto{
-		Name:    scalar.String(string(value.Name())),
-		Number:  scalar.Int32(int32(value.Number())),
+		Name:    proto.String(string(value.Name())),
+		Number:  proto.Int32(int32(value.Number())),
 		Options: clone(value.Options()).(*descriptorpb.EnumValueOptions),
 	}
 }
@@ -181,7 +180,7 @@ func ToEnumValueDescriptorProto(value protoreflect.EnumValueDescriptor) *descrip
 // google.protobuf.ServiceDescriptorProto message.
 func ToServiceDescriptorProto(service protoreflect.ServiceDescriptor) *descriptorpb.ServiceDescriptorProto {
 	p := &descriptorpb.ServiceDescriptorProto{
-		Name:    scalar.String(string(service.Name())),
+		Name:    proto.String(string(service.Name())),
 		Options: clone(service.Options()).(*descriptorpb.ServiceOptions),
 	}
 	for i, methods := 0, service.Methods(); i < methods.Len(); i++ {
@@ -194,16 +193,16 @@ func ToServiceDescriptorProto(service protoreflect.ServiceDescriptor) *descripto
 // google.protobuf.MethodDescriptorProto message.
 func ToMethodDescriptorProto(method protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {
 	p := &descriptorpb.MethodDescriptorProto{
-		Name:       scalar.String(string(method.Name())),
+		Name:       proto.String(string(method.Name())),
 		InputType:  fullNameOf(method.Input()),
 		OutputType: fullNameOf(method.Output()),
 		Options:    clone(method.Options()).(*descriptorpb.MethodOptions),
 	}
 	if method.IsStreamingClient() {
-		p.ClientStreaming = scalar.Bool(true)
+		p.ClientStreaming = proto.Bool(true)
 	}
 	if method.IsStreamingServer() {
-		p.ServerStreaming = scalar.Bool(true)
+		p.ServerStreaming = proto.Bool(true)
 	}
 	return p
 }
@@ -213,9 +212,9 @@ func fullNameOf(d protoreflect.Descriptor) *string {
 		return nil
 	}
 	if strings.HasPrefix(string(d.FullName()), unknownPrefix) {
-		return scalar.String(string(d.FullName()[len(unknownPrefix):]))
+		return proto.String(string(d.FullName()[len(unknownPrefix):]))
 	}
-	return scalar.String("." + string(d.FullName()))
+	return proto.String("." + string(d.FullName()))
 }
 
 func clone(src proto.Message) proto.Message {