]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile/internal/types2: report type of nil based on context
authorRobert Griesemer <gri@golang.org>
Sat, 16 Jan 2021 02:19:00 +0000 (18:19 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 20 Jan 2021 05:50:46 +0000 (05:50 +0000)
commitd8796b5670d46a4197fc5e81a32d127c45ab6557
treeec7789dbc126130c2f0b3d30b1b12695acd6d18f
parent48a3cb399da872554f6ea13e1e92b3c8c73fec95
[dev.typeparams] cmd/compile/internal/types2: report type of nil based on context

With this CL, the type reported for uses of the predeclared
identifier nil changes from untyped nil to the type of the
context within which nil is used, matching the behaviour of
types2 for other untyped types.

If an untyped nil value is assigned or converted to an
interface, the nil expression is given the interface type.

The predicate TypeAndValue.IsNil doesn't change in behavior,
it still reports whether the relevant expression is a (typed
or untyped) nil value.

Change-Id: Id766468f3f3f2a53e4c55e1e6cd521e459c4a94f
Reviewed-on: https://go-review.googlesource.com/c/go/+/284218
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/assignments.go
src/cmd/compile/internal/types2/conversions.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/issues_test.go
src/cmd/compile/internal/types2/operand.go
src/cmd/compile/internal/types2/testdata/stmt0.src
src/cmd/compile/internal/types2/typexpr.go
test/fixedbugs/issue6402.go