aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/subst.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-29 11:10:04 -0700
committerRobert Griesemer <gri@golang.org>2021-08-05 19:36:47 +0000
commitbb5608dd5d056519bd90666b815e0b2bf65e5ee8 (patch)
treece15dcdb79b6a54969dda7ec002a630c71ff40fb /src/cmd/compile/internal/types2/subst.go
parent6dadee759c812961300c8d1a44959d14299fd9f8 (diff)
downloadgo-bb5608dd5d056519bd90666b815e0b2bf65e5ee8.tar.gz
go-bb5608dd5d056519bd90666b815e0b2bf65e5ee8.zip
[dev.typeparams] cmd/compile/internal/types2: implement type sets with term lists
This CL resolves several known issues and TODOs. - Represent type sets with term lists and using term list abstractions. - Represent Unions internally as a list of (syntactical) terms. Use term operations to print terms and detect overlapping union entries. - Compute type sets corresponding to unions lazily, on demand. - Adjust code throughout. - Adjusted error check in test/typeparam/mincheck.dir/main.go to make test pass. Change-Id: Ib36fb7e1d343c2b6aec51d304f0f7d1ad415f999 Reviewed-on: https://go-review.googlesource.com/c/go/+/338310 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.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go
index e497e17463..6c5f756491 100644
--- a/src/cmd/compile/internal/types2/subst.go
+++ b/src/cmd/compile/internal/types2/subst.go
@@ -145,12 +145,12 @@ func (subst *subster) typ(typ Type) Type {
}
case *Union:
- terms, copied := subst.termList(t.terms)
+ terms, copied := subst.termlist(t.terms)
if copied {
- // TODO(gri) Remove duplicates that may have crept in after substitution
- // (unlikely but possible). This matters for the Identical
- // predicate on unions.
- return &Union{terms}
+ // term list substitution may introduce duplicate terms (unlikely but possible).
+ // This is ok; lazy type set computation will determine the actual type set
+ // in normal form.
+ return &Union{terms, nil}
}
case *Interface:
@@ -387,7 +387,7 @@ func (subst *subster) typeList(in []Type) (out []Type, copied bool) {
return
}
-func (subst *subster) termList(in []*term) (out []*term, copied bool) {
+func (subst *subster) termlist(in []*term) (out []*term, copied bool) {
out = in
for i, t := range in {
if u := subst.typ(t.typ); u != t.typ {