aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/subst.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-05-25 17:49:32 -0700
committerRobert Griesemer <gri@golang.org>2021-06-02 20:31:01 +0000
commit589e32dbdf89484d620c635a966c736085cae5c4 (patch)
tree75e1633438a390fa4dab5a4f010e813441636d5c /src/cmd/compile/internal/types2/subst.go
parent7b876def6c4936cfae774d3007f8265876a9fbf7 (diff)
downloadgo-589e32dbdf89484d620c635a966c736085cae5c4.tar.gz
go-589e32dbdf89484d620c635a966c736085cae5c4.zip
[dev.typeparams] cmd/compile/internal/types2: replace Sum type with Union type
- We still mostly ignore the tilde information. - More consistent naming: A Union term is the pair (type, tilde). Rename Union.terms to Union.types; the Union.types and Union.tilde slices make up the Union terms. - Replace Sum.is with Union.underIs: underIs iterates through all union terms and calls its argument function with the underlying type of the term (and thus can ignore the tilde information). This also eliminates the need to call under in the argument function. - Added Union.is for situations where we need to consider the tilde information for each Union term. Change-Id: I70fcf1813e072651dc0f61d52d5555642ee762fd Reviewed-on: https://go-review.googlesource.com/c/go/+/323274 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/subst.go')
-rw-r--r--src/cmd/compile/internal/types2/subst.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go
index a2b81ba0cc..bfec61a065 100644
--- a/src/cmd/compile/internal/types2/subst.go
+++ b/src/cmd/compile/internal/types2/subst.go
@@ -298,21 +298,13 @@ func (subst *subster) typ(typ Type) Type {
}
}
- case *Sum:
- types, copied := subst.typeList(t.types)
- if copied {
- // Don't do it manually, with a Sum literal: the new
- // types list may not be unique and NewSum may remove
- // duplicates.
- return NewSum(types)
- }
-
case *Union:
- terms, copied := subst.typeList(t.terms)
+ types, copied := subst.typeList(t.types)
if copied {
- // TODO(gri) Do we need to remove duplicates that may have
- // crept in after substitution? It may not matter.
- return newUnion(terms, t.tilde)
+ // TODO(gri) Remove duplicates that may have crept in after substitution
+ // (unlikely but possible). This matters for the Identical
+ // predicate on unions.
+ return newUnion(types, t.tilde)
}
case *Interface: