cmd/compile: prevent un-necessary wrapping in switch statement
Follow up discussion in CL 594575.
The wrapping in "any" is only necessary if either casType or tagType is
an interface, as "==" in this situation is implemented by upconverting
to an interface anyway.
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index d23426f..ef284a1 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -1665,7 +1665,7 @@
Outer:
for _, clause := range stmt.Body {
for _, cas := range syntax.UnpackListExpr(clause.Cases) {
- if casType := w.p.typeOf(cas); !types2.AssignableTo(casType, tagType) {
+ if casType := w.p.typeOf(cas); !types2.AssignableTo(casType, tagType) && (types2.IsInterface(casType) || types2.IsInterface(tagType)) {
tagType = types2.NewInterfaceType(nil, nil)
break Outer
}
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |