mirror of
https://github.com/golang/go
synced 2024-11-19 03:24:40 -07:00
e96d959c47
In cases like: type myInt int const ( a = 1 b myInt = 2 ) var foo myInt = <> We now prefer "b" over "a" since b's type matches the expected type exactly. Change-Id: I675934761cc17f6b303b63b4715b31dd1af7cea1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/202737 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package rank
|
|
|
|
func _() {
|
|
type strList []string
|
|
wantsStrList := func(strList) {}
|
|
|
|
var (
|
|
convA string //@item(convertA, "convA", "string", "var")
|
|
convB []string //@item(convertB, "convB", "[]string", "var")
|
|
)
|
|
wantsStrList(strList(conv)) //@complete("))", convertB, convertA)
|
|
}
|
|
|
|
func _() {
|
|
|
|
type myInt int
|
|
|
|
const (
|
|
convC = "hi" //@item(convertC, "convC", "string", "const")
|
|
convD = 123 //@item(convertD, "convD", "int", "const")
|
|
convE int = 123 //@item(convertE, "convE", "int", "const")
|
|
convF string = "there" //@item(convertF, "convF", "string", "const")
|
|
convG myInt = 123 //@item(convertG, "convG", "myInt", "const")
|
|
)
|
|
|
|
var foo int
|
|
foo = conv //@rank(" //", convertE, convertD)
|
|
|
|
var mi myInt
|
|
mi = conv //@rank(" //", convertG, convertD, convertE)
|
|
mi + conv //@rank(" //", convertG, convertD, convertE)
|
|
|
|
1 + conv //@rank(" //", convertD, convertE, convertG)
|
|
|
|
type myString string
|
|
var ms myString
|
|
ms = conv //@rank(" //", convertC, convertF)
|
|
|
|
type myUint uint32
|
|
var mu myUint
|
|
mu = conv //@rank(" //", convertD, convertE)
|
|
}
|