@@ -3,8 +3,11 @@ This file contains tests for hovering over generic Go code.
33Requires go1.20+ for the new go/doc/comment package, and a change in Go 1.20
44that affected the formatting of constraint interfaces.
55
6+ Its size expectations assume a 64-bit machine.
7+
68-- flags --
79-min_go=go1.20
10+ -skip_goarch=386,arm
811
912-- go.mod --
1013// A go.mod is require for correct pkgsite links.
@@ -13,10 +16,28 @@ module mod.com
1316
1417go 1.18
1518
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.
1637-- generics.go --
1738package generics
1839
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)
2041 val T //@hover("T", "T", valuevalT)
2142 Q int64 //@hover("Q", "Q", valueQ)
2243}
@@ -30,51 +51,44 @@ func F[P interface{ ~int | string }]() { //@hover("P", "P", Ptparam)
3051 var _ P //@hover("P","P",Pvar)
3152}
3253
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 --
4855```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+ }
5060```
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 --
5762```go
5863type parameter T any
5964```
60- -- @ValuevalT --
65+ -- @valuevalT --
6166```go
6267type parameter T any
6368```
64- -- @appint --
65- ```go
66- func app(s []int, e int) []int // func[S interface{~[]E}, E interface{}](s S, e E) S
67- ```
6869-- @valueQ --
6970```go
7071field Q int64 // size=8
7172```
7273
7374@hover("Q", "Q", valueQ)
74- -- @valuevalT --
75+ -- @ValueT --
76+ ```go
77+ type parameter T any
78+ ```
79+ -- @ValuevalT --
7580```go
7681type parameter T any
7782```
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)
7892-- @Ptparam --
7993```go
8094type parameter P interface{~int | string}
@@ -83,3 +97,21 @@ type parameter P interface{~int | string}
8397```go
8498type parameter P interface{~int | string}
8599```
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