diff options
| author | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-07-20 13:55:41 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-07-20 13:55:41 +0000 |
| commit | ae43bdc3e3f87f8ba05ba12a17104ddbb0e6b30c (patch) | |
| tree | 08509173f7fb9aa62ed113602e1bc48703c10daf /src/cmd/compile/internal/noder | |
| parent | 7a8ba83b729e37d0bdddc9a3c93ae866d1ef199a (diff) | |
| parent | de649a2a98b2775fad65a06cbbf641545a65a245 (diff) | |
| download | go-ae43bdc3e3f87f8ba05ba12a17104ddbb0e6b30c.tar.xz | |
Merge "[dev.unified] all: merge master (8e1e64c) into dev.unified" into dev.unified
Diffstat (limited to 'src/cmd/compile/internal/noder')
| -rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index cf2f0b38db..1ba561b8b9 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{}. @@ -1354,7 +1357,7 @@ func (g *genInst) dictPass(info *instInfo) { } case ir.ODOTTYPE, ir.ODOTTYPE2: dt := m.(*ir.TypeAssertExpr) - if !dt.Type().HasShape() && !dt.X.Type().HasShape() { + if !dt.Type().HasShape() && !(dt.X.Type().HasShape() && !dt.X.Type().IsEmptyInterface()) { break } var rtype, itab ir.Node @@ -1654,12 +1657,14 @@ func (g *genInst) getDictionarySym(gf *ir.Name, targs []*types.Type, isMeth bool se := call.X.(*ir.SelectorExpr) if se.X.Type().IsShape() { // This is a method call enabled by a type bound. - - // We need this extra check for method expressions, - // which don't add in the implicit XDOTs. - tmpse := ir.NewSelectorExpr(src.NoXPos, ir.OXDOT, se.X, se.Sel) - tmpse = typecheck.AddImplicitDots(tmpse) - tparam := tmpse.X.Type() + tparam := se.X.Type() + if call.X.Op() == ir.ODOTMETH { + // We need this extra check for method expressions, + // which don't add in the implicit XDOTs. + tmpse := ir.NewSelectorExpr(src.NoXPos, ir.OXDOT, se.X, se.Sel) + tmpse = typecheck.AddImplicitDots(tmpse) + tparam = tmpse.X.Type() + } if !tparam.IsShape() { // The method expression is not // really on a typeparam. |
