]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: remove unused position computation (cleanup)
authorRobert Griesemer <gri@golang.org>
Tue, 26 Oct 2021 20:55:53 +0000 (13:55 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 27 Oct 2021 20:25:01 +0000 (20:25 +0000)
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 <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/union.go

index 87985dd13355804ec7f6939897800d73a8dcb049..5379bde02c5db0d448cca75cfb1ad9427ba76277 100644 (file)
@@ -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])
                        }
                }
        })