mirror of
https://github.com/golang/go
synced 2024-11-19 02:04:42 -07:00
719fbf7c21
Fixes golang/go#32414 Change-Id: If08e655d7a0e29b0865c13d8377e98be01cf24c5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/184777 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
45 lines
1.6 KiB
Go
45 lines
1.6 KiB
Go
package func_rank
|
|
|
|
var stringAVar = "var" //@item(stringAVar, "stringAVar", "string", "var")
|
|
func stringBFunc() string { return "str" } //@item(stringBFunc, "stringBFunc", "func() string", "func")
|
|
type stringer struct{} //@item(stringer, "stringer", "struct{...}", "struct")
|
|
|
|
func _() stringer //@complete("tr", stringer, stringAVar, stringBFunc)
|
|
|
|
func _(val stringer) {} //@complete("tr", stringer, stringAVar, stringBFunc)
|
|
|
|
func (stringer) _() {} //@complete("tr", stringer, stringAVar, stringBFunc)
|
|
|
|
func _() {
|
|
var s struct {
|
|
AA int //@item(rankAA, "AA", "int", "field")
|
|
AB string //@item(rankAB, "AB", "string", "field")
|
|
AC int //@item(rankAC, "AC", "int", "field")
|
|
}
|
|
fnStr := func(string) {}
|
|
fnStr(s.A) //@complete(")", rankAB, rankAA, rankAC)
|
|
fnStr("" + s.A) //@complete(")", rankAB, rankAA, rankAC)
|
|
|
|
fnInt := func(int) {}
|
|
fnInt(-s.A) //@complete(")", rankAA, rankAC, rankAB)
|
|
|
|
// no expected type
|
|
fnInt(func() int { s.A }) //@complete(" }", rankAA, rankAB, rankAC)
|
|
fnInt(s.A()) //@complete("()", rankAA, rankAB, rankAC)
|
|
fnInt([]int{}[s.A]) //@complete("])", rankAA, rankAC, rankAB)
|
|
fnInt([]int{}[:s.A]) //@complete("])", rankAA, rankAC, rankAB)
|
|
|
|
fnInt(s.A.(int)) //@complete(".(", rankAA, rankAB, rankAC)
|
|
|
|
fnPtr := func(*string) {}
|
|
fnPtr(&s.A) //@complete(")", rankAB, rankAA, rankAC)
|
|
|
|
var aaPtr *string //@item(rankAAPtr, "aaPtr", "*string", "var")
|
|
var abPtr *int //@item(rankABPtr, "abPtr", "*int", "var")
|
|
fnInt(*a) //@complete(")", rankABPtr, rankAAPtr)
|
|
|
|
_ = func() string {
|
|
return s.A //@complete(" //", rankAB, rankAA, rankAC)
|
|
}
|
|
}
|