diff options
| author | Keith Randall <khr@golang.org> | 2021-09-09 08:09:57 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2021-09-09 15:34:08 +0000 |
| commit | 19457a58e565ff5b480c3806fe02fbc7ccdf32f0 (patch) | |
| tree | 4698c72635ef6c62e1696810aef4ab506af3909d /src/cmd/compile/internal/noder/stencil.go | |
| parent | a295b3cec80b048048bf51a0462764dc337ca6ef (diff) | |
| download | go-19457a58e565ff5b480c3806fe02fbc7ccdf32f0.tar.xz | |
cmd/compile: stenciled conversions might be NOPs
A generic conversion might be required for when converting T->interface{}.
When stenciled with T=interface{}, then that conversion doesn't need
to do anything.
Fixes #48276
Change-Id: Ife65d01c99fbd0895cb7eec79df9e93e752b1fa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/348736
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/noder/stencil.go')
| -rw-r--r-- | src/cmd/compile/internal/noder/stencil.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 1c22fc2ac0..a524ddc2a0 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -1177,6 +1177,12 @@ func (subst *subster) node(n ir.Node) ir.Node { case ir.OCONVIFACE: x := x.(*ir.ConvExpr) + if m.Type().IsEmptyInterface() && m.(*ir.ConvExpr).X.Type().IsEmptyInterface() { + // Was T->interface{}, after stenciling it is now interface{}->interface{}. + // No longer need the conversion. See issue 48276. + m.(*ir.ConvExpr).SetOp(ir.OCONVNOP) + break + } // Note: x's argument is still typed as a type parameter. // m's argument now has an instantiated type. if x.X.Type().HasTParam() || (x.X.Type().IsInterface() && x.Type().HasTParam()) { |
