This test checks definition and hover operations over embedded fields and methods.
Its size expectations assume a 64-bit machine,
and correct sizes information requires go1.21.
-- flags --
-skip_goarch=386,arm
-- go.mod --
module mod.com
go 1.18
-- a/a.go --
package a
type A string //@loc(AString, "A")
func (_ A) Hi() {} //@loc(AHi, "Hi")
type S struct {
Field int //@loc(SField, "Field")
R // embed a struct
H // embed an interface
}
type R struct {
Field2 int //@loc(RField2, "Field2")
}
func (r R) Hey() {} //@loc(RHey, "Hey")
type H interface { //@loc(H, "H")
Goodbye() //@loc(HGoodbye, "Goodbye")
}
type I interface { //@loc(I, "I")
B() //@loc(IB, "B")
J
}
type J interface { //@loc(J, "J")
Hello() //@loc(JHello, "Hello")
}
-- b/b.go --
package b
import "mod.com/a" //@loc(AImport, re"\"[^\"]*\"")
type embed struct {
F int //@loc(F, "F")
}
func (embed) M() //@loc(M, "M")
type Embed struct {
embed
*a.A
a.I
a.S
}
func _() {
e := Embed{}
e.Hi() //@def("Hi", AHi),hover("Hi", "Hi", AHi)
e.B() //@def("B", IB),hover("B", "B", IB)
_ = e.Field //@def("Field", SField),hover("Field", "Field", SField)
_ = e.Field2 //@def("Field2", RField2),hover("Field2", "Field2", RField2)
e.Hello() //@def("Hello", JHello),hover("Hello", "Hello",JHello)
e.Hey() //@def("Hey", RHey),hover("Hey", "Hey", RHey)
e.Goodbye() //@def("Goodbye", HGoodbye),hover("Goodbye", "Goodbye", HGoodbye)
e.M() //@def("M", M),hover("M", "M", M)
_ = e.F //@def("F", F),hover("F", "F", F)
}
type aAlias = a.A //@loc(aAlias, "aAlias")
type S1 struct { //@loc(S1, "S1")
F1 int //@loc(S1F1, "F1")
S2 //@loc(S1S2, "S2"),def("S2", S2),hover("S2", "S2", S2)
a.A //@def("A", AString),hover("A", "A", aA)
aAlias //@def("a", aAlias),hover("a", "aAlias", aAlias)
}
type S2 struct { //@loc(S2, "S2")
F1 string //@loc(S2F1, "F1")
F2 int //@loc(S2F2, "F2")
*a.A //@def("A", AString),def("a",AImport)
}
type S3 struct {
F1 struct {
a.A //@def("A", AString)
}
}
func Bar() {
var x S1 //@def("S1", S1),hover("S1", "S1", S1)
_ = x.S2 //@def("S2", S1S2),hover("S2", "S2", S1S2)
_ = x.F1 //@def("F1", S1F1),hover("F1", "F1", S1F1)
_ = x.F2 //@def("F2", S2F2),hover("F2", "F2", S2F2)
_ = x.S2.F1 //@def("F1", S2F1),hover("F1", "F1", S2F1)
}
-- b/c.go --
package b
var _ = S1{ //@def("S1", S1),hover("S1", "S1", S1)
F1: 99, //@def("F1", S1F1),hover("F1", "F1", S1F1)
}
-- @AHi --
```go
func (a.A) Hi()
```
---
[`(a.A).Hi` on pkg.go.dev](https://pkg.go.dev/mod.com/a#A.Hi)
-- @F --
```go
field F int
```
---
@loc(F, "F")
---
[`(b.Embed).F` on pkg.go.dev](https://pkg.go.dev/mod.com/b#Embed.F)
-- @HGoodbye --
```go
func (a.H) Goodbye()
```
---
@loc(HGoodbye, "Goodbye")
---
[`(a.H).Goodbye` on pkg.go.dev](https://pkg.go.dev/mod.com/a#H.Goodbye)
-- @IB --
```go
func (a.I) B()
```
---
@loc(IB, "B")
---
[`(a.I).B` on pkg.go.dev](https://pkg.go.dev/mod.com/a#I.B)
-- @JHello --
```go
func (a.J) Hello()
```
---
@loc(JHello, "Hello")
---
[`(a.J).Hello` on pkg.go.dev](https://pkg.go.dev/mod.com/a#J.Hello)
-- @M --
```go
func (embed) M()
```
---
[`(b.Embed).M` on pkg.go.dev](https://pkg.go.dev/mod.com/b#Embed.M)
-- @RField2 --
```go
field Field2 int
```
---
@loc(RField2, "Field2")
---
[`(a.R).Field2` on pkg.go.dev](https://pkg.go.dev/mod.com/a#R.Field2)
-- @RHey --
```go
func (r a.R) Hey()
```
---
[`(a.R).Hey` on pkg.go.dev](https://pkg.go.dev/mod.com/a#R.Hey)
-- @S1 --
```go
type S1 struct {
F1 int //@loc(S1F1, "F1")
S2 //@loc(S1S2, "S2"),def("S2", S2),hover("S2", "S2", S2)
a.A //@def("A", AString),hover("A", "A", aA)
aAlias //@def("a", aAlias),hover("a", "aAlias", aAlias)
}
```
---
```go
// Embedded fields:
F2 int // through S2
```
---
[`b.S1` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S1)
-- @S1F1 --
```go
field F1 int
```
---
@loc(S1F1, "F1")
---
[`(b.S1).F1` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S1.F1)
-- @S1S2 --
```go
field S2 S2
```
---
@loc(S1S2, "S2"),def("S2", S2),hover("S2", "S2", S2)
---
[`(b.S1).S2` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S1.S2)
-- @S2 --
```go
type S2 struct { // size=32 (0x20)
F1 string //@loc(S2F1, "F1")
F2 int //@loc(S2F2, "F2")
*a.A //@def("A", AString),def("a",AImport)
}
```
---
```go
func (a.A) Hi()
```
---
[`b.S2` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S2)
-- @S2F1 --
```go
field F1 string
```
---
@loc(S2F1, "F1")
---
[`(b.S2).F1` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S2.F1)
-- @S2F2 --
```go
field F2 int
```
---
@loc(S2F2, "F2")
---
[`(b.S2).F2` on pkg.go.dev](https://pkg.go.dev/mod.com/b#S2.F2)
-- @SField --
```go
field Field int
```
---
@loc(SField, "Field")
---
[`(a.S).Field` on pkg.go.dev](https://pkg.go.dev/mod.com/a#S.Field)
-- @aA --
```go
type A string // size=16 (0x10)
```
---
@loc(AString, "A")
```go
func (a.A) Hi()
```
---
[`a.A` on pkg.go.dev](https://pkg.go.dev/mod.com/a#A)
-- @aAlias --
```go
type aAlias = a.A // size=16 (0x10)
```
---
@loc(aAlias, "aAlias")
```go
func (a.A) Hi()
```