mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: fix CONVIFACE case converting interface to empty interface
We need an extra case in convertToDictionary. In the case of an operand which is an interface and converting to an empty interface, we don't want to get the run-time type from the dictionary (which would be the run-time type of the interface). We want to do a type-assert to the empty interface. Change-Id: I414247210168153151272fab198bfe82ad7b1567 Reviewed-on: https://go-review.googlesource.com/c/go/+/342009 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com>
This commit is contained in:
parent
a304273d74
commit
b7b790a71a
3 changed files with 62 additions and 0 deletions
|
|
@ -1224,6 +1224,11 @@ func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v
|
|||
}
|
||||
assert(ix >= 0)
|
||||
rt = getDictionaryEntry(pos, dictParam, ix, info.dictLen)
|
||||
} else if v.Type().IsInterface() {
|
||||
ta := ir.NewTypeAssertExpr(pos, v, nil)
|
||||
ta.SetType(dst)
|
||||
ta.SetTypecheck(1)
|
||||
return ta
|
||||
} else {
|
||||
ix := findDictType(info, src)
|
||||
assert(ix >= 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue