aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-06-26 13:52:37 -0700
committerGopher Robot <gobot@golang.org>2023-06-26 21:06:37 +0000
commit1dbbafc70fd3e2c284469ab3e0936c1bb56129f6 (patch)
tree16d596f655f8392004afdb8742f9933362b5c97f
parent7cc07405962d804f0386baad100b1b5084dda4c0 (diff)
downloadgo-1dbbafc70fd3e2c284469ab3e0936c1bb56129f6.tar.gz
go-1dbbafc70fd3e2c284469ab3e0936c1bb56129f6.zip
go/types, types2: replace TODO with clarifying comment
This resolves an open question. No non-comment code changes. Change-Id: Idc92794090b2dde694394d1fcd916f6ea61f03e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/506395 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
-rw-r--r--src/cmd/compile/internal/types2/unify.go7
-rw-r--r--src/go/types/unify.go7
2 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types2/unify.go b/src/cmd/compile/internal/types2/unify.go
index 0f1423ff98..94830e94f7 100644
--- a/src/cmd/compile/internal/types2/unify.go
+++ b/src/cmd/compile/internal/types2/unify.go
@@ -410,8 +410,11 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) {
// recorded an underlying type (go.dev/issue/43056).
// Either both types are interfaces, or neither type is.
// If both are interfaces, they have the same methods.
- // TODO(gri) We probably can do this only for inexact
- // unification. Need to find a failure case.
+ //
+ // Note: Changing the recorded type for a type parameter to
+ // a defined type is only ok when unification is inexact.
+ // But in exact unification, if we have a match, x and y must
+ // be identical, so changing the recorded type for x is a no-op.
if yn {
u.set(px, y)
}
diff --git a/src/go/types/unify.go b/src/go/types/unify.go
index 1b1d875dad..bef851f423 100644
--- a/src/go/types/unify.go
+++ b/src/go/types/unify.go
@@ -412,8 +412,11 @@ func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) {
// recorded an underlying type (go.dev/issue/43056).
// Either both types are interfaces, or neither type is.
// If both are interfaces, they have the same methods.
- // TODO(gri) We probably can do this only for inexact
- // unification. Need to find a failure case.
+ //
+ // Note: Changing the recorded type for a type parameter to
+ // a defined type is only ok when unification is inexact.
+ // But in exact unification, if we have a match, x and y must
+ // be identical, so changing the recorded type for x is a no-op.
if yn {
u.set(px, y)
}