aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/predicates.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-11-01 12:14:25 -0700
committerRobert Griesemer <gri@golang.org>2021-11-02 16:11:43 +0000
commitd39c8739662835b2f92894a8550bbcd59f83557f (patch)
treed8dc3c3f0ce3a104a2c5e743a31ae3af8a74d1e5 /src/cmd/compile/internal/types2/predicates.go
parentc3cb1ecc36512a00492f27fa3ba19e5dad6194f1 (diff)
downloadgo-d39c8739662835b2f92894a8550bbcd59f83557f.tar.gz
go-d39c8739662835b2f92894a8550bbcd59f83557f.zip
cmd/compile/internal/types2: fix conversions of constants to type parameter
When converting a constant to a type parameter, the result is never constant (type parameters are not constant types), but we still need to verfy that the constant is representable by each specific type in the type set of the type parameter. Fixes #49247. Change-Id: I460983c7070b33baadce25dd23210e10930cfb2c Reviewed-on: https://go-review.googlesource.com/c/go/+/360396 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/predicates.go')
-rw-r--r--src/cmd/compile/internal/types2/predicates.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go
index 380fb6489c..6d93a8a227 100644
--- a/src/cmd/compile/internal/types2/predicates.go
+++ b/src/cmd/compile/internal/types2/predicates.go
@@ -80,6 +80,12 @@ func IsInterface(typ Type) bool {
return asInterface(typ) != nil
}
+// isTypeParam reports whether typ is a type parameter.
+func isTypeParam(typ Type) bool {
+ _, ok := under(typ).(*TypeParam)
+ return ok
+}
+
// Comparable reports whether values of type T are comparable.
func Comparable(T Type) bool {
return comparable(T, nil)