aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/conversions.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-03-17 22:13:16 -0700
committerRobert Griesemer <gri@golang.org>2021-03-23 05:11:09 +0000
commit8f19394b62a5b1651cd66eefb1bfeacc278966b9 (patch)
treeaf9e7e1c97239a9283eedd30c49f437e4acb054d /src/cmd/compile/internal/types2/conversions.go
parent0265b6475f08f2c23a742132db87c357fcbfa458 (diff)
downloadgo-8f19394b62a5b1651cd66eefb1bfeacc278966b9.tar.gz
go-8f19394b62a5b1651cd66eefb1bfeacc278966b9.zip
cmd/compile/internal/types2: refactor untyped conversions
Based on https://golang.org/cl/284256 for go/types. Brings this code more in line with go/types. Adjusted various tests to match new error messages which generally are now better: for assignment errors, instead of a generic "cannot convert" we now say "cannot use" followed by a clearer reason as to why not. Major differences to go/types with respect to the changed files: - Some of the new code now returns error codes, but they are only used internally for now, and not reported with errors. - go/types does not "convert" untyped nil values to target types, but here we do. This is unchanged from how types2 handled this before this CL. Change-Id: If45336d7ee679ece100f6d9d9f291a6ea55004d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/302757 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/conversions.go')
-rw-r--r--src/cmd/compile/internal/types2/conversions.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go
index d04ccec411..eabed7ba9b 100644
--- a/src/cmd/compile/internal/types2/conversions.go
+++ b/src/cmd/compile/internal/types2/conversions.go
@@ -83,7 +83,7 @@ func (check *Checker) conversion(x *operand, T Type) {
// exported API call, i.e., when all methods have been type-checked.
func (x *operand) convertibleTo(check *Checker, T Type) bool {
// "x is assignable to T"
- if x.assignableTo(check, T, nil) {
+ if ok, _ := x.assignableTo(check, T, nil); ok {
return true
}