Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gotypes: Handle named types in Component.Resolve #383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/args/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Struct struct {
Int8 int8
Uint16 uint16
Int32 int32
Uint64 uint64
Uint64 NamedUint64
Float32 float32
Float64 float64
String string
Expand Down
4 changes: 3 additions & 1 deletion examples/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Struct struct {
Int8 int8
Uint16 uint16
Int32 int32
Uint64 uint64
Uint64 NamedUint64
Float32 float32
Float64 float64
String string
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/args/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) }},
Expand Down
2 changes: 1 addition & 1 deletion gotypes/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down