mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 03:03:27 +00:00
reflect: make sure pointerTo() works for named types
This commit is contained in:
@@ -490,6 +490,10 @@ func PointerTo(t Type) Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pointerTo(t *rawType) *rawType {
|
func pointerTo(t *rawType) *rawType {
|
||||||
|
if t.isNamed() {
|
||||||
|
return (*elemType)(unsafe.Pointer(t)).ptrTo
|
||||||
|
}
|
||||||
|
|
||||||
switch t.Kind() {
|
switch t.Kind() {
|
||||||
case Pointer:
|
case Pointer:
|
||||||
// TODO(dgryski): This is blocking https://github.com/tinygo-org/tinygo/issues/3131
|
// TODO(dgryski): This is blocking https://github.com/tinygo-org/tinygo/issues/3131
|
||||||
|
|||||||
@@ -275,6 +275,14 @@ func TestNamedTypes(t *testing.T) {
|
|||||||
t.Errorf("Type.String(base64.Encoding{})=%v, want %v", got, want)
|
t.Errorf("Type.String(base64.Encoding{})=%v, want %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Repository struct {
|
||||||
|
RoleName *string `json:"role_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var repo *Repository
|
||||||
|
v := ValueOf(&repo).Elem()
|
||||||
|
n := New(v.Type().Elem())
|
||||||
|
v.Set(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStruct(t *testing.T) {
|
func TestStruct(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user