Skip to content

Commit 8f43cce

Browse files
committed
Go: consider TypeArgs
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent f473236 commit 8f43cce

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Units/parser-go.r/go-generics.d/expected.tags

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ F0 input.go /^func F0[L ~[]M, M comparable, _, G any](s L, v M) int {$/;" f pack
1313
N input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:~[]O nth:0
1414
O input.go /^func F1[N ~[]O, O comparable, _ any](s N, v O) int {$/;" Z func:x.F1 typeref:constraint:comparable nth:1
1515
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]
16+
E input.go /^type Set[E comparable] struct {$/;" Z struct:x.Set typeref:constraint:comparable nth:0
17+
Set input.go /^type Set[E comparable] struct {$/;" s package:x tparams:[E comparable]
18+
m input.go /^ m map[E]struct{}$/;" m struct:x.Set typeref:typename:map[E]struct{}
19+
E input.go /^func New[E comparable]() *Set[E] {$/;" Z func:x.New typeref:constraint:comparable nth:0
20+
New input.go /^func New[E comparable]() *Set[E] {$/;" f package:x typeref:typename:*Set[E] signature:() tparams:[E comparable]
1621
T input.go /^type List[T any] struct {$/;" Z struct:x.List typeref:constraint:any nth:0
1722
List input.go /^type List[T any] struct {$/;" s package:x tparams:[T any]
18-
next input.go /^ next *List[T]$/;" m struct:x.List typeref:typename:*List
23+
next input.go /^ next *List[T]$/;" m struct:x.List typeref:typename:*List[T]
1924
value input.go /^ value T$/;" m struct:x.List typeref:typename:T
2025
UUIDBuflen input.go /^ UUIDBuflen = 256$/;" c package:x
2126
UUID input.go /^type UUID [UUIDBuflen]byte$/;" t package:x typeref:typename:[UUIDBuflen]byte

Units/parser-go.r/go-generics.d/input.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ func F1[N ~[]O, O comparable, _ any](s N, v O) int {
3131
return -1
3232
}
3333

34+
// podman/vendor/github.com/containers/image/v5/internal/set/set.go
35+
type Set[E comparable] struct {
36+
m map[E]struct{}
37+
}
38+
39+
func New[E comparable]() *Set[E] {
40+
return &Set[E]{
41+
m: map[E]struct{}{},
42+
}
43+
}
44+
3445
// Taken from https://go.dev/ref/spec#Type_definitions
3546
type List[T any] struct {
3647
next *List[T]

parsers/go.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static void skipToMatched (tokenInfo *const token, collector *collector)
643643

644644
static bool skipType (tokenInfo *const token, collector *collector)
645645
{
646-
// Type = TypeName | TypeLit | "(" Type ")" .
646+
// Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
647647
// Skips also function multiple return values "(" Type {"," Type} ")"
648648
if (isType (token, TOKEN_OPEN_PAREN))
649649
{
@@ -663,6 +663,8 @@ static bool skipType (tokenInfo *const token, collector *collector)
663663
if (isType (token, TOKEN_IDENTIFIER))
664664
readTokenFull (token, collector);
665665
}
666+
else if (isType (token, TOKEN_OPEN_SQUARE))
667+
skipToMatched (token, collector);
666668
return true;
667669
}
668670

0 commit comments

Comments
 (0)