From 6a7eb56cd1837b961ea815105235a3fd96fda94b Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 26 Oct 2021 13:55:53 -0700 Subject: [PATCH] cmd/compile/internal/types2: remove unused position computation (cleanup) The position computation was needed for type list support. With that gone, we don't need this code anymore. Change-Id: I3f36b3d108a1fae9947fd259d4892e0287cb78ef Reviewed-on: https://go-review.googlesource.com/c/go/+/358701 Trust: Robert Griesemer Reviewed-by: Robert Findley --- src/cmd/compile/internal/types2/union.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/cmd/compile/internal/types2/union.go b/src/cmd/compile/internal/types2/union.go index 87985dd133..5379bde02c 100644 --- a/src/cmd/compile/internal/types2/union.go +++ b/src/cmd/compile/internal/types2/union.go @@ -75,28 +75,16 @@ func parseUnion(check *Checker, tlist []syntax.Expr) Type { continue } - x := tlist[i] - pos := syntax.StartPos(x) - // We may not know the position of x if it was a typechecker- - // introduced ~T term for a type list entry T. Use the position - // of T instead. - // TODO(gri) remove this test once we don't support type lists anymore - if !pos.IsKnown() { - if op, _ := x.(*syntax.Operation); op != nil { - pos = syntax.StartPos(op.X) - } - } - u := under(t.typ) f, _ := u.(*Interface) if t.tilde { if f != nil { - check.errorf(x, "invalid use of ~ (%s is an interface)", t.typ) + check.errorf(tlist[i], "invalid use of ~ (%s is an interface)", t.typ) continue // don't report another error for t } if !Identical(u, t.typ) { - check.errorf(x, "invalid use of ~ (underlying type of %s is %s)", t.typ, u) + check.errorf(tlist[i], "invalid use of ~ (underlying type of %s is %s)", t.typ, u) continue // don't report another error for t } } @@ -105,14 +93,14 @@ func parseUnion(check *Checker, tlist []syntax.Expr) Type { // in the beginning. Embedded interfaces with tilde are excluded above. If we reach // here, we must have at least two terms in the union. if f != nil && !f.typeSet().IsTypeSet() { - check.errorf(pos, "cannot use %s in union (interface contains methods)", t) + check.errorf(tlist[i], "cannot use %s in union (interface contains methods)", t) continue // don't report another error for t } // Report overlapping (non-disjoint) terms such as // a|a, a|~a, ~a|~a, and ~a|A (where under(A) == a). if j := overlappingTerm(terms[:i], t); j >= 0 { - check.softErrorf(pos, "overlapping terms %s and %s", t, terms[j]) + check.softErrorf(tlist[i], "overlapping terms %s and %s", t, terms[j]) } } })