-
Notifications
You must be signed in to change notification settings - Fork 650
Go: support generics #4397
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
Open
masatake
wants to merge
4
commits into
universal-ctags:master
Choose a base branch
from
masatake:go--generics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Go: support generics #4397
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --sort=no | ||
| --fields=+{signature}{nth} | ||
| --kinds-Go=+{tparam} | ||
| --fields-Go=+{tparams} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| x input.go /^package x$/;" p | ||
| T input.go /^func min[T ~int|~float64](x, y T) T {$/;" Z func:x.min typeref:constraint:~int|~float64 nth:0 | ||
| min input.go /^func min[T ~int|~float64](x, y T) T {$/;" f package:x typeref:typename:T signature:(x, y T) tparams:[T ~int|~float64] | ||
| S1 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:~[]E1 nth:0 | ||
| S2 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:~[]E2 nth:1 | ||
| E1 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:any nth:2 | ||
| E2 input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" Z func:x.EqualFunc typeref:constraint:any nth:3 | ||
| EqualFunc input.go /^func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool {$/;" f package:x typeref:typename:bool signature:(s1 S1, s2 S2, eq func(E1, E2) bool) tparams:[S1 ~[]E1, S2 ~[]E2, E1, E2 any] | ||
| L input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:~[]M nth:0 | ||
| M input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:comparable nth:1 | ||
| G input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" Z func:x.F0 typeref:constraint:any nth:3 | ||
| F0 input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" f package:x typeref:typename:int signature:(s L, v M) tparams:[L ~[]M, M comparable, _, G any] | ||
| N input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:~[]O nth:0 | ||
| O input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:comparable nth:1 | ||
| F1 input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" f package:x typeref:typename:int signature:(s N, v O) tparams:[N ~[]O, O comparable, _ any] | ||
| E input.go /^type Set[E comparable] struct {$/;" Z struct:x.Set typeref:constraint:comparable nth:0 | ||
| Set input.go /^type Set[E comparable] struct {$/;" s package:x tparams:[E comparable] | ||
| m input.go /^ m map[E]struct{}$/;" m struct:x.Set typeref:typename:map[E]struct{} | ||
| E input.go /^func New[E comparable]() *Set[E] {$/;" Z func:x.New typeref:constraint:comparable nth:0 | ||
| New input.go /^func New[E comparable]() *Set[E] {$/;" f package:x typeref:typename:*Set[E] signature:() tparams:[E comparable] | ||
| T input.go /^type List[T any] struct {$/;" Z struct:x.List typeref:constraint:any nth:0 | ||
| List input.go /^type List[T any] struct {$/;" s package:x tparams:[T any] | ||
| next input.go /^ next *List[T]$/;" m struct:x.List typeref:typename:*List[T] | ||
| value input.go /^ value T$/;" m struct:x.List typeref:typename:T | ||
| X input.go /^type List2[X any] = []X$/;" Z talias:x.List2 typeref:constraint:any nth:0 | ||
| List2 input.go /^type List2[X any] = []X$/;" a package:x typeref:typename:[]X tparams:[X any] | ||
| K input.go /^type Assoc[K comparable, V any] = map[K]V$/;" Z talias:x.Assoc typeref:constraint:comparable nth:0 | ||
| V input.go /^type Assoc[K comparable, V any] = map[K]V$/;" Z talias:x.Assoc typeref:constraint:any nth:1 | ||
| Assoc input.go /^type Assoc[K comparable, V any] = map[K]V$/;" a package:x typeref:typename:map[K]V tparams:[K comparable, V any] | ||
| UUIDBuflen input.go /^ UUIDBuflen = 256$/;" c package:x | ||
| UUID input.go /^type UUID [UUIDBuflen]byte$/;" t package:x typeref:typename:[UUIDBuflen]byte |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package x | ||
|
|
||
| // Taken from https://go.dev/ref/spec#Function_types | ||
| func min[T ~int|~float64](x, y T) T { | ||
| if x < y { | ||
| return x | ||
| } | ||
| return y | ||
| } | ||
|
|
||
|
|
||
| // Taken from podman/vendor/golang.org/x/exp/slices/slices.go | ||
| func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool { | ||
| if len(s1) != len(s2) { | ||
| return false | ||
| } | ||
| for i, v1 := range s1 { | ||
| v2 := s2[i] | ||
| if !eq(v1, v2) { | ||
| return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| func F0[L ~[]M, M comparable, _, G any](s L, v M) int { | ||
| return -1 | ||
| } | ||
|
|
||
| func F1[N ~[]O, O comparable, _ any](s N, v O) int { | ||
| return -1 | ||
| } | ||
|
|
||
| // podman/vendor/github.com/containers/image/v5/internal/set/set.go | ||
| type Set[E comparable] struct { | ||
| m map[E]struct{} | ||
| } | ||
|
|
||
| func New[E comparable]() *Set[E] { | ||
| return &Set[E]{ | ||
| m: map[E]struct{}{}, | ||
| } | ||
| } | ||
|
|
||
| // Taken from https://go.dev/ref/spec#Type_definitions | ||
| type List[T any] struct { | ||
| next *List[T] | ||
| value T | ||
| } | ||
|
|
||
| // Aliases | ||
| type List2[X any] = []X | ||
| type Assoc[K comparable, V any] = map[K]V | ||
|
|
||
| // Taken from podman/vendor/github.com/digitalocean/go-libvirt/remote_protocol.gen.go | ||
| const ( | ||
| UUIDBuflen = 256 | ||
| ) | ||
| type UUID [UUIDBuflen]byte | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.