encoding/protojson, encoding/prototext: remove most explicit registries

Change tests which use private types registries to use the global one.
Except in cases where we want to explicitly test that the private
registry is used, it's simpler to use the global registry.

Change-Id: I998fb463b6beef91c7f5ce2ca2083251ae24d1db
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/199897
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Herbie Ong <herbie@google.com>
diff --git a/encoding/protojson/decode_test.go b/encoding/protojson/decode_test.go
index e5385f4..0d3d312 100644
--- a/encoding/protojson/decode_test.go
+++ b/encoding/protojson/decode_test.go
@@ -10,7 +10,6 @@
 
 	"google.golang.org/protobuf/encoding/protojson"
 	"google.golang.org/protobuf/internal/flags"
-	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -1899,10 +1898,7 @@
 		inputText:    `{}`,
 		wantMessage:  &anypb.Any{},
 	}, {
-		desc: "Any with non-custom message",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any with non-custom message",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "foo/pb2.Nested",
@@ -1928,24 +1924,18 @@
 			}
 		}(),
 	}, {
-		desc: "Any with empty embedded message",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any with empty embedded message",
 		inputMessage: &anypb.Any{},
 		inputText:    `{"@type": "foo/pb2.Nested"}`,
 		wantMessage:  &anypb.Any{TypeUrl: "foo/pb2.Nested"},
 	}, {
 		desc:         "Any without registered type",
-		umo:          protojson.UnmarshalOptions{Resolver: preg.NewTypes()},
+		umo:          protojson.UnmarshalOptions{Resolver: new(preg.Types)},
 		inputMessage: &anypb.Any{},
 		inputText:    `{"@type": "foo/pb2.Nested"}`,
 		wantErr:      true,
 	}, {
-		desc: "Any with missing required",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
-		},
+		desc:         "Any with missing required",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "pb2.PartialRequired",
@@ -1971,7 +1961,6 @@
 		desc: "Any with partial required and AllowPartial",
 		umo: protojson.UnmarshalOptions{
 			AllowPartial: true,
-			Resolver:     preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
 		},
 		inputMessage: &anypb.Any{},
 		inputText: `{
@@ -1995,10 +1984,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with invalid UTF8",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any with invalid UTF8",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "optString": "` + "abc\xff" + `",
@@ -2006,10 +1992,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with BoolValue",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.BoolValue{})),
-		},
+		desc:         "Any with BoolValue",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "type.googleapis.com/google.protobuf.BoolValue",
@@ -2027,10 +2010,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with Empty",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
-		},
+		desc:         "Any with Empty",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "value": {},
@@ -2040,20 +2020,14 @@
 			TypeUrl: "type.googleapis.com/google.protobuf.Empty",
 		},
 	}, {
-		desc: "Any with missing Empty",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
-		},
+		desc:         "Any with missing Empty",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "type.googleapis.com/google.protobuf.Empty"
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with StringValue containing invalid UTF8",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{})),
-		},
+		desc:         "Any with StringValue containing invalid UTF8",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.StringValue",
@@ -2061,10 +2035,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with Int64Value",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.Int64Value{})),
-		},
+		desc:         "Any with Int64Value",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.Int64Value",
@@ -2082,10 +2053,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with invalid Int64Value",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.Int64Value{})),
-		},
+		desc:         "Any with invalid Int64Value",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.Int64Value",
@@ -2093,10 +2061,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with invalid UInt64Value",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.UInt64Value{})),
-		},
+		desc:         "Any with invalid UInt64Value",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.UInt64Value",
@@ -2104,10 +2069,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with Duration",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&durationpb.Duration{})),
-		},
+		desc:         "Any with Duration",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "type.googleapis.com/google.protobuf.Duration",
@@ -2125,10 +2087,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with Value of StringValue",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&structpb.Value{})),
-		},
+		desc:         "Any with Value of StringValue",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.Value",
@@ -2136,10 +2095,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with Value of NullValue",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&structpb.Value{})),
-		},
+		desc:         "Any with Value of NullValue",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.Value",
@@ -2157,16 +2113,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with Struct",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(
-				pimpl.Export{}.MessageTypeOf(&structpb.Struct{}),
-				pimpl.Export{}.MessageTypeOf(&structpb.Value{}),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.BoolValue{}),
-				pimpl.Export{}.EnumTypeOf(structpb.NullValue_NULL_VALUE),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{}),
-			),
-		},
+		desc:         "Any with Struct",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.Struct",
@@ -2221,13 +2168,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with duplicate @type",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(
-				pimpl.Export{}.MessageTypeOf(&pb2.Nested{}),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{}),
-			),
-		},
+		desc:         "Any with duplicate @type",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.StringValue",
@@ -2236,10 +2177,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with duplicate value",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{})),
-		},
+		desc:         "Any with duplicate value",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "google.protobuf.StringValue",
@@ -2248,10 +2186,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with unknown field",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any with unknown field",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "pb2.Nested",
@@ -2260,14 +2195,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "Any with embedded type containing Any",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(
-				pimpl.Export{}.MessageTypeOf(&pb2.KnownTypes{}),
-				pimpl.Export{}.MessageTypeOf(&anypb.Any{}),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{}),
-			),
-		},
+		desc:         "Any with embedded type containing Any",
 		inputMessage: &anypb.Any{},
 		inputText: `{
   "@type": "pb2.KnownTypes",
@@ -2278,10 +2206,7 @@
 }`,
 		wantErr: true,
 	}, {
-		desc: "well known types as field values",
-		umo: protojson.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
-		},
+		desc:         "well known types as field values",
 		inputMessage: &pb2.KnownTypes{},
 		inputText: `{
   "optBool": false,
@@ -2435,7 +2360,6 @@
 		desc: "DiscardUnknown: Any",
 		umo: protojson.UnmarshalOptions{
 			DiscardUnknown: true,
-			Resolver:       preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
 		},
 		inputMessage: &anypb.Any{},
 		inputText: `{
@@ -2449,7 +2373,6 @@
 		desc: "DiscardUnknown: Any with Empty",
 		umo: protojson.UnmarshalOptions{
 			DiscardUnknown: true,
-			Resolver:       preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
 		},
 		inputMessage: &anypb.Any{},
 		inputText: `{
diff --git a/encoding/protojson/encode_test.go b/encoding/protojson/encode_test.go
index 38e60e7..9ee9f25 100644
--- a/encoding/protojson/encode_test.go
+++ b/encoding/protojson/encode_test.go
@@ -14,7 +14,6 @@
 	"google.golang.org/protobuf/internal/detrand"
 	"google.golang.org/protobuf/internal/encoding/pack"
 	"google.golang.org/protobuf/internal/flags"
-	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -1492,9 +1491,6 @@
 		want:  `{}`,
 	}, {
 		desc: "Any with non-custom message",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
 				OptString: proto.String("embedded inside Any"),
@@ -1519,24 +1515,18 @@
   }
 }`,
 	}, {
-		desc: "Any with empty embedded message",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:  "Any with empty embedded message",
 		input: &anypb.Any{TypeUrl: "foo/pb2.Nested"},
 		want: `{
   "@type": "foo/pb2.Nested"
 }`,
 	}, {
 		desc:    "Any without registered type",
-		mo:      protojson.MarshalOptions{Resolver: preg.NewTypes()},
+		mo:      protojson.MarshalOptions{Resolver: new(preg.Types)},
 		input:   &anypb.Any{TypeUrl: "foo/pb2.Nested"},
 		wantErr: true,
 	}, {
 		desc: "Any with missing required",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
-		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
 				OptString: proto.String("embedded inside Any"),
@@ -1561,7 +1551,6 @@
 		desc: "Any with partial required and AllowPartial",
 		mo: protojson.MarshalOptions{
 			AllowPartial: true,
-			Resolver:     preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
 		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
@@ -1585,9 +1574,6 @@
 }`,
 	}, {
 		desc: "Any with invalid UTF8",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
 				OptString: proto.String("abc\xff"),
@@ -1604,9 +1590,6 @@
 		wantErr: true,
 	}, {
 		desc: "Any with invalid value",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
 		input: &anypb.Any{
 			TypeUrl: "foo/pb2.Nested",
 			Value:   []byte("\x80"),
@@ -1614,9 +1597,6 @@
 		wantErr: true,
 	}, {
 		desc: "Any with BoolValue",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.BoolValue{})),
-		},
 		input: func() proto.Message {
 			m := &wrapperspb.BoolValue{Value: true}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1634,9 +1614,6 @@
 }`,
 	}, {
 		desc: "Any with Empty",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
-		},
 		input: func() proto.Message {
 			m := &emptypb.Empty{}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1654,9 +1631,6 @@
 }`,
 	}, {
 		desc: "Any with StringValue containing invalid UTF8",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{})),
-		},
 		input: func() proto.Message {
 			m := &wrapperspb.StringValue{Value: "abcd"}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1671,9 +1645,6 @@
 		wantErr: true,
 	}, {
 		desc: "Any with Int64Value",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.Int64Value{})),
-		},
 		input: func() proto.Message {
 			m := &wrapperspb.Int64Value{Value: 42}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1691,9 +1662,6 @@
 }`,
 	}, {
 		desc: "Any with Duration",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&durationpb.Duration{})),
-		},
 		input: func() proto.Message {
 			m := &durationpb.Duration{}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1711,9 +1679,6 @@
 }`,
 	}, {
 		desc: "Any with empty Value",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&structpb.Value{})),
-		},
 		input: func() proto.Message {
 			m := &structpb.Value{}
 			b, err := proto.Marshal(m)
@@ -1728,9 +1693,6 @@
 		wantErr: true,
 	}, {
 		desc: "Any with Value of StringValue",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&structpb.Value{})),
-		},
 		input: func() proto.Message {
 			m := &structpb.Value{Kind: &structpb.Value_StringValue{"abcd"}}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1745,9 +1707,6 @@
 		wantErr: true,
 	}, {
 		desc: "Any with Value of NullValue",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&structpb.Value{})),
-		},
 		input: func() proto.Message {
 			m := &structpb.Value{Kind: &structpb.Value_NullValue{}}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1765,15 +1724,6 @@
 }`,
 	}, {
 		desc: "Any with Struct",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(
-				pimpl.Export{}.MessageTypeOf(&structpb.Struct{}),
-				pimpl.Export{}.MessageTypeOf(&structpb.Value{}),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.BoolValue{}),
-				pimpl.Export{}.EnumTypeOf(structpb.NullValue_NULL_VALUE),
-				pimpl.Export{}.MessageTypeOf(&wrapperspb.StringValue{}),
-			),
-		},
 		input: func() proto.Message {
 			m := &structpb.Struct{
 				Fields: map[string]*structpb.Value{
@@ -1813,9 +1763,6 @@
 }`,
 	}, {
 		desc: "Any with missing type_url",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&wrapperspb.BoolValue{})),
-		},
 		input: func() proto.Message {
 			m := &wrapperspb.BoolValue{Value: true}
 			b, err := proto.MarshalOptions{Deterministic: true}.Marshal(m)
@@ -1829,9 +1776,6 @@
 		wantErr: true,
 	}, {
 		desc: "well known types as field values",
-		mo: protojson.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&emptypb.Empty{})),
-		},
 		input: &pb2.KnownTypes{
 			OptBool:      &wrapperspb.BoolValue{Value: false},
 			OptInt32:     &wrapperspb.Int32Value{Value: 42},
diff --git a/encoding/prototext/decode_test.go b/encoding/prototext/decode_test.go
index c9df319..03ba552 100644
--- a/encoding/prototext/decode_test.go
+++ b/encoding/prototext/decode_test.go
@@ -10,7 +10,6 @@
 
 	"google.golang.org/protobuf/encoding/prototext"
 	"google.golang.org/protobuf/internal/flags"
-	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -1400,10 +1399,7 @@
 			Value: []byte("some bytes"),
 		},
 	}, {
-		desc: "Any expanded",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any expanded",
 		inputMessage: &anypb.Any{},
 		inputText: `
 [foobar/pb2.Nested]: {
@@ -1430,20 +1426,14 @@
 			}
 		}(),
 	}, {
-		desc: "Any expanded with empty value",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any expanded with empty value",
 		inputMessage: &anypb.Any{},
 		inputText:    `[foo.com/pb2.Nested]: {}`,
 		wantMessage: &anypb.Any{
 			TypeUrl: "foo.com/pb2.Nested",
 		},
 	}, {
-		desc: "Any expanded with missing required",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
-		},
+		desc:         "Any expanded with missing required",
 		inputMessage: &anypb.Any{},
 		inputText: `
 [pb2.PartialRequired]: {
@@ -1467,10 +1457,7 @@
 			}
 		}(),
 	}, {
-		desc: "Any with invalid UTF-8",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb3.Nested{})),
-		},
+		desc:         "Any with invalid UTF-8",
 		inputMessage: &anypb.Any{},
 		inputText: `
 [pb3.Nested]: {
@@ -1480,23 +1467,17 @@
 		wantErr: true,
 	}, {
 		desc:         "Any expanded with unregistered type",
-		umo:          prototext.UnmarshalOptions{Resolver: preg.NewTypes()},
+		umo:          prototext.UnmarshalOptions{Resolver: new(preg.Types)},
 		inputMessage: &anypb.Any{},
 		inputText:    `[SomeMessage]: {}`,
 		wantErr:      true,
 	}, {
-		desc: "Any expanded with invalid value",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any expanded with invalid value",
 		inputMessage: &anypb.Any{},
 		inputText:    `[pb2.Nested]: 123`,
 		wantErr:      true,
 	}, {
-		desc: "Any expanded with unknown fields",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any expanded with unknown fields",
 		inputMessage: &anypb.Any{},
 		inputText: `
 [pb2.Nested]: {}
@@ -1504,10 +1485,7 @@
 `,
 		wantErr: true,
 	}, {
-		desc: "Any contains expanded and unexpanded fields",
-		umo: prototext.UnmarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
+		desc:         "Any contains expanded and unexpanded fields",
 		inputMessage: &anypb.Any{},
 		inputText: `
 [pb2.Nested]: {}
diff --git a/encoding/prototext/encode_test.go b/encoding/prototext/encode_test.go
index 68ceb45..ec5a225 100644
--- a/encoding/prototext/encode_test.go
+++ b/encoding/prototext/encode_test.go
@@ -13,7 +13,6 @@
 	"google.golang.org/protobuf/internal/detrand"
 	"google.golang.org/protobuf/internal/encoding/pack"
 	"google.golang.org/protobuf/internal/flags"
-	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -1130,7 +1129,7 @@
 	}, {
 		desc: "Any not expanded",
 		mo: prototext.MarshalOptions{
-			Resolver: preg.NewTypes(),
+			Resolver: new(preg.Types),
 		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
@@ -1153,9 +1152,6 @@
 `,
 	}, {
 		desc: "Any expanded",
-		mo: prototext.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
 		input: func() proto.Message {
 			m := &pb2.Nested{
 				OptString: proto.String("embedded inside Any"),
@@ -1181,9 +1177,6 @@
 `,
 	}, {
 		desc: "Any expanded with missing required",
-		mo: prototext.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.PartialRequired{})),
-		},
 		input: func() proto.Message {
 			m := &pb2.PartialRequired{
 				OptString: proto.String("embedded inside Any"),
@@ -1206,9 +1199,6 @@
 `,
 	}, {
 		desc: "Any with invalid value",
-		mo: prototext.MarshalOptions{
-			Resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
-		},
 		input: &anypb.Any{
 			TypeUrl: "foo/pb2.Nested",
 			Value:   []byte("\x80"),
diff --git a/encoding/prototext/other_test.go b/encoding/prototext/other_test.go
index 3ffa071..0ae4ba6 100644
--- a/encoding/prototext/other_test.go
+++ b/encoding/prototext/other_test.go
@@ -8,8 +8,6 @@
 	"testing"
 
 	"google.golang.org/protobuf/encoding/prototext"
-	"google.golang.org/protobuf/internal/impl"
-	pimpl "google.golang.org/protobuf/internal/impl"
 	"google.golang.org/protobuf/proto"
 	preg "google.golang.org/protobuf/reflect/protoregistry"
 
@@ -151,7 +149,7 @@
 		},
 	}, {
 		desc:     "Any field without registered type",
-		resolver: preg.NewTypes(),
+		resolver: new(preg.Types),
 		message: func() proto.Message {
 			m := &pb2.Nested{
 				OptString: proto.String("embedded inside Any"),
@@ -171,8 +169,7 @@
 			}
 		}(),
 	}, {
-		desc:     "Any field with registered type",
-		resolver: preg.NewTypes(pimpl.Export{}.MessageTypeOf(&pb2.Nested{})),
+		desc: "Any field with registered type",
 		message: func() *pb2.KnownTypes {
 			m := &pb2.Nested{
 				OptString: proto.String("embedded inside Any"),
@@ -193,11 +190,6 @@
 		}(),
 	}, {
 		desc: "Any field containing Any message",
-		resolver: func() *preg.Types {
-			mt1 := impl.Export{}.MessageTypeOf(&pb2.Nested{})
-			mt2 := impl.Export{}.MessageTypeOf(&anypb.Any{})
-			return preg.NewTypes(mt1, mt2)
-		}(),
 		message: func() *pb2.KnownTypes {
 			m1 := &pb2.Nested{
 				OptString: proto.String("message inside Any of another Any field"),