[go] cmd/compile: prevent un-necessary wrapping in switch statement

1 view
Skip to first unread message

Cuong Manh Le (Gerrit)

unread,
1:35 PM (8 hours ago) 1:35 PM
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Cuong Manh Le has uploaded the change for review

Commit message

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.
Change-Id: I73da771d25685a23eec612ac696965c892db4764

Change diff

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
}

Change information

Files:
  • M src/cmd/compile/internal/noder/writer.go
Change size: XS
Delta: 1 file changed, 1 insertion(+), 1 deletion(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I73da771d25685a23eec612ac696965c892db4764
Gerrit-Change-Number: 596555
Gerrit-PatchSet: 1
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Cuong Manh Le (Gerrit)

unread,
1:39 PM (8 hours ago) 1:39 PM
to goph...@pubsubhelper.golang.org, Keith Randall, golang-co...@googlegroups.com
Attention needed from Keith Randall

Cuong Manh Le voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Keith Randall
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I73da771d25685a23eec612ac696965c892db4764
Gerrit-Change-Number: 596555
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Attention: Keith Randall <k...@golang.org>
Gerrit-Comment-Date: Wed, 03 Jul 2024 17:39:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
2:07 PM (7 hours ago) 2:07 PM
to Cuong Manh Le, goph...@pubsubhelper.golang.org, Keith Randall, Go LUCI, golang-co...@googlegroups.com
Attention needed from Cuong Manh Le

Keith Randall voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Cuong Manh Le
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedNo-Wait-Release
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I73da771d25685a23eec612ac696965c892db4764
Gerrit-Change-Number: 596555
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Comment-Date: Wed, 03 Jul 2024 18:06:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Keith Randall (Gerrit)

unread,
2:07 PM (7 hours ago) 2:07 PM
to Cuong Manh Le, goph...@pubsubhelper.golang.org, Keith Randall, Go LUCI, golang-co...@googlegroups.com
Attention needed from Cuong Manh Le

Keith Randall voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Cuong Manh Le
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedNo-Wait-Release
  • requirement is not satisfiedReview-Enforcement
  • requirement satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I73da771d25685a23eec612ac696965c892db4764
Gerrit-Change-Number: 596555
Gerrit-PatchSet: 2
Gerrit-Owner: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Attention: Cuong Manh Le <cuong.m...@gmail.com>
Gerrit-Comment-Date: Wed, 03 Jul 2024 18:07:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages