diff options
author | Robert Griesemer <gri@golang.org> | 2021-02-17 17:56:34 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-02-18 20:47:17 +0000 |
commit | 099374b55e8aed17d1e77a1084f8fb78ff2f8162 (patch) | |
tree | a93d6b9f5cd0c51a25b3072cddba372c85c850c0 /src/cmd/compile/internal/types2/stmt.go | |
parent | 653386a89a702b54bb01be893cfd30cddb0e6107 (diff) | |
download | go-099374b55e8aed17d1e77a1084f8fb78ff2f8162.tar.gz go-099374b55e8aed17d1e77a1084f8fb78ff2f8162.zip |
[dev.typeparams] cmd/compile/internal/types2: remove Type.Under method in favor of function
This removes the need for the aType embedded type and brings the types2.Type
API in sync with the go/types.Type API.
For reasons not fully understood yet, introducing the new under function
causes a very long initialization cycle error, which doesn't exist in
go/types. For now, circumvent the problem through a helper function variable.
This CL also eliminates superflous (former) Under() method calls
inside optype calls (optype takes care of this).
Plus some minor misc. cleanups and comment adjustments.
Change-Id: I86e13ccf6f0b34d7496240ace61a1c84856b6033
Reviewed-on: https://go-review.googlesource.com/c/go/+/293470
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/types2/stmt.go')
-rw-r--r-- | src/cmd/compile/internal/types2/stmt.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index 9d74e0e588..490cd0fc19 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -680,7 +680,7 @@ func (check *Checker) typeSwitchStmt(inner stmtContext, s *syntax.SwitchStmt, gu if x.mode == invalid { return } - xtyp, _ := x.typ.Under().(*Interface) + xtyp, _ := under(x.typ).(*Interface) if xtyp == nil { check.errorf(&x, "%s is not an interface type", &x) return @@ -769,7 +769,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s // determine key/value types var key, val Type if x.mode != invalid { - typ := optype(x.typ.Under()) + typ := optype(x.typ) if _, ok := typ.(*Chan); ok && sValue != nil { // TODO(gri) this also needs to happen for channels in generic variables check.softErrorf(sValue, "range over %s permits only one iteration variable", &x) @@ -906,7 +906,7 @@ func rangeKeyVal(typ Type, wantKey, wantVal bool) (Type, Type, string) { var key, val Type var msg string typ.is(func(t Type) bool { - k, v, m := rangeKeyVal(t.Under(), wantKey, wantVal) + k, v, m := rangeKeyVal(under(t), wantKey, wantVal) if k == nil || m != "" { key, val, msg = k, v, m return false |