From 6ca930a00ac0e4e0c649392012a6030aa77eefe1 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 22 Jun 2020 16:45:13 -0700 Subject: [PATCH] [dev.go2go] go/types: add internal TODO for future simplification Change-Id: I8e4e8eebf8c64962ccf5f0e225dd007f691c373a Reviewed-on: https://go-review.googlesource.com/c/go/+/239384 Reviewed-by: Robert Griesemer --- src/go/types/expr.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/go/types/expr.go b/src/go/types/expr.go index 29c874b7a3..d9b65ba509 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -513,6 +513,9 @@ func (check *Checker) convertUntyped(x *operand, target Type) { // In case of a type parameter, conversion must succeed against // all types enumerated by the type parameter bound. + // TODO(gri) We should not need this because we have the code + // for Sum types in convertUntypedInternal. But at least one + // test fails. Investigate. if t := target.TypeParam(); t != nil { types := t.Bound().allTypes if types == nil { @@ -585,6 +588,11 @@ func (check *Checker) convertUntypedInternal(x *operand, target Type) { goto Error } } + case *Sum: + t.is(func(t Type) bool { + check.convertUntypedInternal(x, t) + return x.mode != invalid + }) case *Interface: // Update operand types to the default type rather then // the target (interface) type: values must have concrete