mirror of
https://github.com/golang/go
synced 2024-11-19 05:34:40 -07:00
49797d04a8
In cases like: var foo *someType = bar.(some<>) We will now complete "some" to "*someType". This involved two changes: 1. Properly detect expected type as *someType in above example. To do this I just removed *ast.TypeAssertExpr from breaksExpectedTypeInference() so we continue searching up the AST for the expected type. 2. If the given type name T doesn't match, also try *T. If *T does match, we mark the candidate as "makePointer=true" so we know to prepend the "*" when formatting the candidate. Change-Id: I05859c68082a798141755b614673a1483d864e3e Reviewed-on: https://go-review.googlesource.com/c/tools/+/212717 Run-TryBot: Muir Manders <muir@mnd.rs> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
19 lines
548 B
Go
19 lines
548 B
Go
package maps
|
|
|
|
func _() {
|
|
var aVar int //@item(mapVar, "aVar", "int", "var")
|
|
|
|
// not comparabale
|
|
type aSlice []int //@item(mapSliceType, "aSlice", "[]int", "type")
|
|
|
|
*aSlice //@item(mapSliceTypePtr, "*aSlice", "[]int", "type")
|
|
|
|
// comparable
|
|
type aStruct struct{} //@item(mapStructType, "aStruct", "struct{...}", "struct")
|
|
|
|
map[]a{} //@complete("]", mapSliceTypePtr, mapStructType, mapVar)
|
|
|
|
map[a]a{} //@complete("]", mapSliceTypePtr, mapStructType, mapVar)
|
|
map[a]a{} //@complete("{", mapSliceType, mapStructType, mapVar)
|
|
}
|