1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:21:37 -07:00
This commit is contained in:
Carl Johnson 2023-07-26 21:18:31 -04:00
parent 61672c99a0
commit becd714c45
3 changed files with 3 additions and 3 deletions

View File

@ -1 +1 @@
pkg reflect, func TypeFor[$0 interface{}]() Type
pkg reflect, func TypeFor[$0 interface{}]() Type #60088

View File

@ -2910,7 +2910,7 @@ func addTypeBits(bv *bitVector, offset uintptr, t *abi.Type) {
}
}
// TypeFor returns the reflection Type that represents the static type of T.
// TypeFor returns the [Type] that represents the type argument T.
func TypeFor[T any]() Type {
return TypeOf((*T)(nil)).Elem()
}

View File

@ -29,7 +29,7 @@ func TestTypeFor(t *testing.T) {
for _, tc := range testcases {
want := reflect.ValueOf(tc.wantFrom).Elem().Type()
if want != tc.got {
t.Errorf("unexpected reflect.Type: want %v; got %v", want, tc.got)
t.Errorf("unexpected reflect.Type: got %v; want %v", tc.got, want)
}
}
}