From e9306ff1f7405e6c0978f10a797a6f0ad2b880df Mon Sep 17 00:00:00 2001 From: greatroar <61184462+greatroar@users.noreply.github.com> Date: Fri, 17 Mar 2023 11:40:27 +0100 Subject: [PATCH] gotypes: Handle named types in Component.Resolve --- examples/args/README.md | 2 +- examples/args/args.go | 4 +++- examples/args/args_test.go | 2 +- gotypes/components.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/args/README.md b/examples/args/README.md index 8032cc7f..cf260518 100644 --- a/examples/args/README.md +++ b/examples/args/README.md @@ -71,7 +71,7 @@ type Struct struct { Int8 int8 Uint16 uint16 Int32 int32 - Uint64 uint64 + Uint64 NamedUint64 Float32 float32 Float64 float64 String string diff --git a/examples/args/args.go b/examples/args/args.go index 679bc613..1de21e5b 100644 --- a/examples/args/args.go +++ b/examples/args/args.go @@ -6,7 +6,7 @@ type Struct struct { Int8 int8 Uint16 uint16 Int32 int32 - Uint64 uint64 + Uint64 NamedUint64 Float32 float32 Float64 float64 String string @@ -16,6 +16,8 @@ type Struct struct { Complex128 complex128 } +type NamedUint64 uint64 + // Sub is a sub-struct of Struct, to demonstrate nested datastructure accesses. type Sub struct { A uint64 diff --git a/examples/args/args_test.go b/examples/args/args_test.go index 8d1b406c..4ba6286e 100644 --- a/examples/args/args_test.go +++ b/examples/args/args_test.go @@ -21,7 +21,7 @@ func TestFunctionsEqual(t *testing.T) { {FieldInt8, func(s Struct) int8 { return s.Int8 }}, {FieldUint16, func(s Struct) uint16 { return s.Uint16 }}, {FieldInt32, func(s Struct) int32 { return s.Int32 }}, - {FieldUint64, func(s Struct) uint64 { return s.Uint64 }}, + {FieldUint64, func(s Struct) uint64 { return uint64(s.Uint64) }}, {FieldFloat32, func(s Struct) float32 { return s.Float32 }}, {FieldFloat64, func(s Struct) float64 { return s.Float64 }}, {FieldStringLen, func(s Struct) int { return len(s.String) }}, diff --git a/gotypes/components.go b/gotypes/components.go index 81524342..876467a2 100644 --- a/gotypes/components.go +++ b/gotypes/components.go @@ -74,7 +74,7 @@ func NewComponent(t types.Type, addr operand.Mem) Component { } func (c *component) Resolve() (*Basic, error) { - b := toprimitive(c.typ) + b := toprimitive(c.typ.Underlying()) if b == nil { return nil, errors.New("component is not primitive") }