Skip to content

Commit

Permalink
Use Go 1.22 unalias (#3471)
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Coffman <steve@khanacademy.org>
  • Loading branch information
StevenACoffman authored Jan 7, 2025
1 parent 6d7a5d9 commit 630f3e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion codegen/config/binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (ref *TypeReference) IsPtrToSlice() bool {

func (ref *TypeReference) IsPtrToIntf() bool {
if ref.IsPtr() {
_, isPointerToInterface := ref.GO.(*types.Pointer).Elem().(*types.Interface)
_, isPointerToInterface := types.Unalias(ref.GO.(*types.Pointer).Elem()).(*types.Interface)
return isPointerToInterface
}
return false
Expand Down
12 changes: 8 additions & 4 deletions internal/code/alias.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
//go:build !go1.23

package code

import (
"go/types"
)

// Unalias unwraps an alias type
// TODO: Drop this function when we drop support for go1.22
func Unalias(t types.Type) types.Type {
return t // No-op
if p, ok := t.(*types.Pointer); ok {
// If the type come from auto-binding,
// it will be a pointer to an alias type.
// (e.g: `type Cursor = entgql.Cursor[int]`)
// *ent.Cursor is the type we got from auto-binding.
return types.NewPointer(Unalias(p.Elem()))
}
return types.Unalias(t)
}
19 changes: 0 additions & 19 deletions internal/code/alias_1.23.go

This file was deleted.

0 comments on commit 630f3e9

Please sign in to comment.