Skip to content

Commit 61defc0

Browse files
committed
go/types/typeutil: compute correct core type for <-chan E | chan E
We failed to account for bidirectional channels following unidirectional channels in the term list. Fixes gh-1304 (cherry picked from commit edb67bc)
1 parent ae2dc16 commit 61defc0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

go/types/typeutil/typeparams.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ func (ts TypeSet) CoreType() types.Type {
5252
// typ is currently a bidirectional channel. The term's type is either also bidirectional, or
5353
// unidirectional. Use the term's type.
5454
typ = ut
55+
} else if ch2.Dir() == types.SendRecv {
56+
// typ is currently a unidirectional channel and the term's type is bidirectional, which means it has no
57+
// effect.
58+
continue
5559
} else if ch1.Dir() != ch2.Dir() {
5660
// typ is not bidirectional and typ and term disagree about the direction
5761
return nil

0 commit comments

Comments
 (0)