Skip to content

Commit

Permalink
Merge pull request #347 from Jorropo/fix-structural-typing
Browse files Browse the repository at this point in the history
fix panic when packaged go code relies on structural typing
  • Loading branch information
rcoreilly authored Apr 22, 2024
2 parents be58ca3 + 4f1a712 commit 0050491
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bind/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,15 @@ func (p *Package) process() error {
funcs[name] = fv

case *types.TypeName:
named := obj.Type().(*types.Named)
switch typ := named.Underlying().(type) {
typ := obj.Type()
if named, ok := typ.(*types.Named); ok {
typ = named.Underlying()
} else {
// we are dealing with a type alias to a type literal.
// this is a cursed feature used to do structural typing.
// just pass it as-is.
}
switch typ := typ.(type) {
case *types.Struct:
sv, err := newStruct(p, obj)
if err != nil {
Expand Down

0 comments on commit 0050491

Please sign in to comment.