mirror of
https://github.com/golang/go
synced 2024-11-26 00:48:01 -07:00
internal/reflectlite: fix name of type parameter
CL 372774 is for reflect, this CL is for internal/reflectlite. Updates #50208 Change-Id: Ib7e8b1bc031feab218d1addd78388fcfe9b675b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/393918 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
4d2da99498
commit
47efdcbf4c
@ -958,6 +958,9 @@ type nameTest struct {
|
|||||||
want string
|
want string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type A struct{}
|
||||||
|
type B[T any] struct{}
|
||||||
|
|
||||||
var nameTests = []nameTest{
|
var nameTests = []nameTest{
|
||||||
{(*int32)(nil), "int32"},
|
{(*int32)(nil), "int32"},
|
||||||
{(*D1)(nil), "D1"},
|
{(*D1)(nil), "D1"},
|
||||||
@ -971,6 +974,8 @@ var nameTests = []nameTest{
|
|||||||
F()
|
F()
|
||||||
})(nil), ""},
|
})(nil), ""},
|
||||||
{(*TheNameOfThisTypeIsExactly255BytesLongSoWhenTheCompilerPrependsTheReflectTestPackageNameAndExtraStarTheLinkerRuntimeAndReflectPackagesWillHaveToCorrectlyDecodeTheSecondLengthByte0123456789_0123456789_0123456789_0123456789_0123456789_012345678)(nil), "TheNameOfThisTypeIsExactly255BytesLongSoWhenTheCompilerPrependsTheReflectTestPackageNameAndExtraStarTheLinkerRuntimeAndReflectPackagesWillHaveToCorrectlyDecodeTheSecondLengthByte0123456789_0123456789_0123456789_0123456789_0123456789_012345678"},
|
{(*TheNameOfThisTypeIsExactly255BytesLongSoWhenTheCompilerPrependsTheReflectTestPackageNameAndExtraStarTheLinkerRuntimeAndReflectPackagesWillHaveToCorrectlyDecodeTheSecondLengthByte0123456789_0123456789_0123456789_0123456789_0123456789_012345678)(nil), "TheNameOfThisTypeIsExactly255BytesLongSoWhenTheCompilerPrependsTheReflectTestPackageNameAndExtraStarTheLinkerRuntimeAndReflectPackagesWillHaveToCorrectlyDecodeTheSecondLengthByte0123456789_0123456789_0123456789_0123456789_0123456789_012345678"},
|
||||||
|
{(*B[A])(nil), "B[reflectlite_test.A]"},
|
||||||
|
{(*B[B[A]])(nil), "B[reflectlite_test.B[reflectlite_test.A]]"},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNames(t *testing.T) {
|
func TestNames(t *testing.T) {
|
||||||
|
@ -577,7 +577,14 @@ func (t *rtype) Name() string {
|
|||||||
}
|
}
|
||||||
s := t.String()
|
s := t.String()
|
||||||
i := len(s) - 1
|
i := len(s) - 1
|
||||||
for i >= 0 && s[i] != '.' {
|
sqBrackets := 0
|
||||||
|
for i >= 0 && (s[i] != '.' || sqBrackets != 0) {
|
||||||
|
switch s[i] {
|
||||||
|
case ']':
|
||||||
|
sqBrackets++
|
||||||
|
case '[':
|
||||||
|
sqBrackets--
|
||||||
|
}
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
return s[i+1:]
|
return s[i+1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user