]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.21] go/types, types2: remove order dependency in inference involv...
authorRobert Griesemer <gri@golang.org>
Mon, 21 Aug 2023 22:50:18 +0000 (15:50 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 30 Aug 2023 21:35:21 +0000 (21:35 +0000)
commitb120517ffd415a6a12835b916df7505001cfe583
treeba6cc73673bac1f9220c572f706065ab66f9d913
parent0a9582163c3392ea0e51cadec9ee5fc5c46cfeee
[release-branch.go1.21] go/types, types2: remove order dependency in inference involving channels

In inexact unification, when a named type matches against an inferred
unnamed type, we change the previously inferred type to the named type.
This preserves the type name and assignability.

We have to do the same thing when encountering a directional channel:
a bidirectional channel can always be assigned to a directional channel
but not the other way around. Thus, if we see a directional channel, we
must choose the directional channel.

This CL extends the previously existing logic for named types to
directional channels and also makes the code conditional on inexact
unification. The latter is an optimization - if unification is exact,
type differences don't exist and updating an already inferred type has
no effect.

Fixes #62205.

Change-Id: I807e3b9f9ab363f9ed848bdb18b2577b1d680ea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/524256
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/unify.go
src/go/types/unify.go
src/internal/types/testdata/fixedbugs/issue62157.go [new file with mode: 0644]