@@ -3,8 +3,11 @@ This file contains tests for hovering over generic Go code.
3
3
Requires go1.20+ for the new go/doc/comment package, and a change in Go 1.20
4
4
that affected the formatting of constraint interfaces.
5
5
6
+ Its size expectations assume a 64-bit machine.
7
+
6
8
-- flags --
7
9
-min_go=go1.20
10
+ -skip_goarch=386,arm
8
11
9
12
-- go.mod --
10
13
// A go.mod is require for correct pkgsite links.
@@ -13,10 +16,28 @@ module mod.com
13
16
14
17
go 1.18
15
18
19
+ -- issue68213.go --
20
+ package generics
21
+
22
+ // Hovering over an interface with empty type set must not panic.
23
+ type empty interface { //@hover("empty", "empty", empty)
24
+ int
25
+ string
26
+ }
27
+
28
+ -- @empty --
29
+ ```go
30
+ type empty interface { // size=16 (0x10)
31
+ int
32
+ string
33
+ }
34
+ ```
35
+
36
+ Hovering over an interface with empty type set must not panic.
16
37
-- generics.go --
17
38
package generics
18
39
19
- type value[T any] struct { //hover("lue", "value", value),hover("T", "T", valueT)
40
+ type value[T any] struct { //@ hover("lue", "value", value),hover("T", "T", valueT)
20
41
val T //@hover("T", "T", valuevalT)
21
42
Q int64 //@hover("Q", "Q", valueQ)
22
43
}
@@ -30,51 +51,44 @@ func F[P interface{ ~int | string }]() { //@hover("P", "P", Ptparam)
30
51
var _ P //@hover("P","P",Pvar)
31
52
}
32
53
33
- -- inferred.go --
34
- package generics
35
-
36
- func app[S interface{ ~[]E }, E interface{}](s S, e E) S {
37
- return append(s, e)
38
- }
39
-
40
- func _() {
41
- _ = app[[]int] //@hover("app", "app", appint)
42
- _ = app[[]int, int] //@hover("app", "app", appint)
43
- _ = app[[]int]([]int{}, 0) //@hover("app", "app", appint), diag("[[]int]", re"unnecessary")
44
- _ = app([]int{}, 0) //@hover("app", "app", appint)
45
- }
46
-
47
- -- @ValueQ --
54
+ -- @value --
48
55
```go
49
- field Q int64 // size=8
56
+ type value[T any] struct {
57
+ val T //@hover("T", "T", valuevalT)
58
+ Q int64 //@hover("Q", "Q", valueQ)
59
+ }
50
60
```
51
-
52
- @hover("Q", "Q", ValueQ)
53
-
54
-
55
- [`(generics.Value).Q` on pkg.go.dev](https://pkg.go.dev/mod.com#Value.Q)
56
- -- @ValueT --
61
+ -- @valueT --
57
62
```go
58
63
type parameter T any
59
64
```
60
- -- @ValuevalT --
65
+ -- @valuevalT --
61
66
```go
62
67
type parameter T any
63
68
```
64
- -- @appint --
65
- ```go
66
- func app(s []int, e int) []int // func[S interface{~[]E}, E interface{}](s S, e E) S
67
- ```
68
69
-- @valueQ --
69
70
```go
70
71
field Q int64 // size=8
71
72
```
72
73
73
74
@hover("Q", "Q", valueQ)
74
- -- @valuevalT --
75
+ -- @ValueT --
76
+ ```go
77
+ type parameter T any
78
+ ```
79
+ -- @ValuevalT --
75
80
```go
76
81
type parameter T any
77
82
```
83
+ -- @ValueQ --
84
+ ```go
85
+ field Q int64 // size=8
86
+ ```
87
+
88
+ @hover("Q", "Q", ValueQ)
89
+
90
+
91
+ [`(generics.Value).Q` on pkg.go.dev](https://pkg.go.dev/mod.com#Value.Q)
78
92
-- @Ptparam --
79
93
```go
80
94
type parameter P interface{~int | string}
@@ -83,3 +97,21 @@ type parameter P interface{~int | string}
83
97
```go
84
98
type parameter P interface{~int | string}
85
99
```
100
+ -- inferred.go --
101
+ package generics
102
+
103
+ func app[S interface{ ~[]E }, E interface{}](s S, e E) S {
104
+ return append(s, e)
105
+ }
106
+
107
+ func _() {
108
+ _ = app[[]int] //@hover("app", "app", appint)
109
+ _ = app[[]int, int] //@hover("app", "app", appint)
110
+ _ = app[[]int]([]int{}, 0) //@hover("app", "app", appint), diag("[[]int]", re"unnecessary")
111
+ _ = app([]int{}, 0) //@hover("app", "app", appint)
112
+ }
113
+
114
+ -- @appint --
115
+ ```go
116
+ func app(s []int, e int) []int // func[S interface{~[]E}, E interface{}](s S, e E) S
117
+ ```
0 commit comments