diff options
author | Dan Scales <danscales@google.com> | 2021-08-12 17:08:49 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-08-17 13:23:13 +0000 |
commit | b7b790a71a86678f036b7d30a892c5f792c5092f (patch) | |
tree | 6289c12416efbbddd25016fff4c1ca3c08c1c7f0 /src/cmd/compile/internal/noder | |
parent | a304273d74b95c835ee08b641a17ce6bc591ddd3 (diff) | |
download | go-b7b790a71a86678f036b7d30a892c5f792c5092f.tar.gz go-b7b790a71a86678f036b7d30a892c5f792c5092f.zip |
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>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 6736f128e3..4ac37c362c 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -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) |