]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/types2: differently named types are not assignable
authorRobert Griesemer <gri@golang.org>
Sun, 31 Oct 2021 17:37:15 +0000 (10:37 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 1 Nov 2021 15:55:20 +0000 (15:55 +0000)
commitd2b512160e4fc9dd69947ad9566c2dab1a135694
tree9e76255e30e0511d7dabd22235b0cbc1381f5ff8
parent82f902ae8e2b7f7eff0cdb087e47e939cc296a62
cmd/compile/internal/types2: differently named types are not assignable

When checking assignability, a value of a named type (incl. a type parameter)
can never be assigned to a variable of a differently named type. Specifically,
if the types are two differently named type parameters, then values of one are
never assignable to variables of the other.

This CL clarifies the assignabiliy rules and simplifies the implementation.

Fixes #49242.

Change-Id: Id72a2c9bed5cdb726855e7a707137db1009e7953
Reviewed-on: https://go-review.googlesource.com/c/go/+/360274
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/operand.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue49242.go2 [new file with mode: 0644]
src/cmd/compile/internal/types2/testdata/spec/assignability.go2