diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-07-01 16:33:54 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2022-07-08 12:57:49 +0000 |
| commit | 14abe8aa7324bdf0e09e1dfebfb3519cc30f4918 (patch) | |
| tree | 32ee6f7c497700886022b6f9b6df375509a3ba67 /src/cmd/compile/internal/noder | |
| parent | 1ebc983000ed411a1c06f6b8a61770be1392e707 (diff) | |
| download | go-14abe8aa7324bdf0e09e1dfebfb3519cc30f4918.tar.xz | |
cmd/compile: don't convert to interface{} for un-comparable types in generic switch
Fixes #53635
Change-Id: I41f383be8870432fc0d29fa83687911ddd8217f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/415634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
| -rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 796a740528..1534a1fa49 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1214,6 +1214,9 @@ func (subst *subster) node(n ir.Node) ir.Node { if m.Tag != nil && m.Tag.Op() == ir.OTYPESW { break // Nothing to do here for type switches. } + if m.Tag != nil && !types.IsComparable(m.Tag.Type()) { + break // Nothing to do here for un-comparable types. + } if m.Tag != nil && !m.Tag.Type().IsEmptyInterface() && m.Tag.Type().HasShape() { // To implement a switch on a value that is or has a type parameter, we first convert // that thing we're switching on to an interface{}. |
