Skip to content

Commit

Permalink
Fixes #899
Browse files Browse the repository at this point in the history
  • Loading branch information
lu4p committed Jan 19, 2025
1 parent e6c0aef commit 95d8fd7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,11 @@ func recordType(used, origin types.Type, done map[*types.Named]bool, fieldToStru
// Ensure we record the original generic struct, if there is one.
recordType(used.Underlying(), used.Origin().Underlying(), done, fieldToStruct)
case *types.Struct:
origin := origin.(*types.Struct)
origin, ok := origin.(*types.Struct)
if !ok {
return
}

for i := range used.NumFields() {
field := used.Field(i)
fieldToStruct[field] = origin
Expand Down
8 changes: 6 additions & 2 deletions testdata/script/typeparams.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type GenericVector[GenericParamT any] []GenericParamT

type GenericGraph[T any] struct {
Content T
Edges []GenericGraph[T]
Edges []GenericGraph[T]
}

type PredeclaredSignedInteger interface {
Expand All @@ -40,7 +40,7 @@ type StringableSignedInteger interface {
type CombineEmbeds interface {
string | int

interface { EmbeddedMethod() }
interface{ EmbeddedMethod() }
RegularMethod()
}

Expand All @@ -49,3 +49,7 @@ type Slice[T any] []T
func sliceOfPointer() Slice[*any] {
return []*any{}
}

type Map[K, V comparable] map[K]V

var _ = Map[string, struct{}]{}

0 comments on commit 95d8fd7

Please sign in to comment.