| 1 |
This test checks that hover reports accessible embedded fields |
| 2 |
(after the doc comment and before the accessible methods). |
| 3 |
|
| 4 |
-- go.mod -- |
| 5 |
module example.com |
| 6 |
|
| 7 |
go 1.18 |
| 8 |
|
| 9 |
-- q/q.go -- |
| 10 |
package q |
| 11 |
|
| 12 |
type Q struct { |
| 13 |
One int |
| 14 |
two string |
| 15 |
q2[chan int] |
| 16 |
} |
| 17 |
|
| 18 |
type q2[T any] struct { |
| 19 |
Three *T |
| 20 |
four string |
| 21 |
} |
| 22 |
|
| 23 |
-- p.go -- |
| 24 |
package p |
| 25 |
|
| 26 |
import "example.com/q" |
| 27 |
|
| 28 |
// doc |
| 29 |
type P struct { |
| 30 |
q.Q |
| 31 |
} |
| 32 |
|
| 33 |
func (P) m() {} |
| 34 |
|
| 35 |
var p P //@hover("P", "P", P) |
| 36 |
|
| 37 |
var _, _ = P.m, p // pacify unusedfunc |
| 38 |
|
| 39 |
type A struct { |
| 40 |
*B |
| 41 |
} |
| 42 |
|
| 43 |
type B struct { |
| 44 |
*C |
| 45 |
} |
| 46 |
|
| 47 |
type C struct { |
| 48 |
*D |
| 49 |
} |
| 50 |
|
| 51 |
type D struct { |
| 52 |
E int |
| 53 |
} |
| 54 |
|
| 55 |
type X struct{ |
| 56 |
*Y |
| 57 |
} |
| 58 |
|
| 59 |
type Y struct { |
| 60 |
*Z |
| 61 |
} |
| 62 |
|
| 63 |
type Z struct{ |
| 64 |
z int |
| 65 |
} |
| 66 |
|
| 67 |
type E[T any] struct { |
| 68 |
Value T |
| 69 |
} |
| 70 |
|
| 71 |
type F struct { |
| 72 |
E[string] |
| 73 |
} |
| 74 |
|
| 75 |
func _() { |
| 76 |
var f F |
| 77 |
f.Value = "hello" //@hover("Value", "Value", Value) |
| 78 |
} |
| 79 |
|
| 80 |
var a A |
| 81 |
var _ = a.E //@hover("E", "E", E) |
| 82 |
|
| 83 |
var x struct { |
| 84 |
*X |
| 85 |
} |
| 86 |
var _ = x.z //@hover("z", "z", Z) |
| 87 |
|
| 88 |
type Al2 = int |
| 89 |
type N struct{ |
| 90 |
x Al2 |
| 91 |
y struct{ ZA } |
| 92 |
} |
| 93 |
type Al = *N |
| 94 |
type S struct{ Al } |
| 95 |
type ZA = *Z |
| 96 |
var _ = new(S).x //@hover("x", "x", X) |
| 97 |
var _ = new(S).y.z //@hover("z", "z", Zz), hover("y", "y", y) |
| 98 |
|
| 99 |
-- @P -- |
| 100 |
```go |
| 101 |
type P struct { |
| 102 |
q.Q |
| 103 |
} |
| 104 |
``` |
| 105 |
|
| 106 |
--- |
| 107 |
|
| 108 |
doc |
| 109 |
|
| 110 |
|
| 111 |
```go |
| 112 |
// Embedded fields: |
| 113 |
One int // through Q |
| 114 |
Three *chan int // through Q.q2 |
| 115 |
``` |
| 116 |
|
| 117 |
```go |
| 118 |
func (P) m() |
| 119 |
``` |
| 120 |
|
| 121 |
--- |
| 122 |
|
| 123 |
[`p.P` on pkg.go.dev](https://pkg.go.dev/example.com#P) |
| 124 |
-- @E -- |
| 125 |
```go |
| 126 |
field E int // through *B, *C, *D |
| 127 |
``` |
| 128 |
|
| 129 |
--- |
| 130 |
|
| 131 |
[`(p.D).E` on pkg.go.dev](https://pkg.go.dev/example.com#D.E) |
| 132 |
-- @Value -- |
| 133 |
```go |
| 134 |
field Value string // through E[string] |
| 135 |
``` |
| 136 |
|
| 137 |
--- |
| 138 |
|
| 139 |
[`(p.E).Value` on pkg.go.dev](https://pkg.go.dev/example.com#E.Value) |
| 140 |
-- @Z -- |
| 141 |
```go |
| 142 |
field z int // through *X, *Y, *Z |
| 143 |
``` |
| 144 |
-- @X -- |
| 145 |
```go |
| 146 |
field x Al2 // through Al |
| 147 |
``` |
| 148 |
-- @Zz -- |
| 149 |
```go |
| 150 |
field z int // through ZA |
| 151 |
``` |
| 152 |
-- @y -- |
| 153 |
```go |
| 154 |
field y struct{ZA} // through Al |
| 155 |
``` |