]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] go/types: conversions to type parameters are not constant
authorRob Findley <rfindley@google.com>
Thu, 11 Feb 2021 16:54:46 +0000 (11:54 -0500)
committerRobert Findley <rfindley@google.com>
Thu, 18 Feb 2021 14:58:11 +0000 (14:58 +0000)
commit7b679617f3bb532fe65d8e83365b9f1f41b01b00
tree8741f1d702f23aeebff04b5f861968bb206c6668
parentf5d0c653e68589f835df7f9a832f2cb9df0b3931
[dev.typeparams] go/types: conversions to type parameters are not constant

This is a port of CL 290471 to go/types. However, this change preserves
the existing check for constant types in recordTypeAndValue, which uses
is(..., isConstType) rather than the isConstType predicate. In types2,
this code path is not hit with type parameters because convertUntyped
walks the type list in order before calling updateExprType with the type
parameter, at which point the expression type would have already been
recorded as the first element of the type list -- probably something
that should be corrected.

Longer term, I believe we actually could allow const type parameters if
the optype is a sum of constant types.

Change-Id: Iaa91ffa740b5f08a5696bd96918a866bffd7aef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/291323
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/check.go
src/go/types/examples/types.go2
src/go/types/predicates.go