aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/universe.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-07-26 14:50:57 -0700
committerRobert Griesemer <gri@golang.org>2021-07-27 21:21:00 +0000
commitc751e2e6ba30fc319c93b9cfe207dc7d1b48c3fb (patch)
treed4b7355ff1fe7ed9b985d1a6f639957863d7f9c5 /src/cmd/compile/internal/types2/universe.go
parent5d8f90f90405e9faa9c5425627024d2cfa67faa3 (diff)
downloadgo-c751e2e6ba30fc319c93b9cfe207dc7d1b48c3fb.tar.gz
go-c751e2e6ba30fc319c93b9cfe207dc7d1b48c3fb.zip
[dev.typeparams] cmd/compile/internal/types2: use comparable bit rather than ==() method
This removes the special "==" methods from comparable interfaces in favor of a "comparable" flag in TypeSets indicating that the interface is or embeds comparable. Fixes various related implementation inaccuracies. While at it, fix setup of the predeclared error and comparable interface types by associating their respective type name objects with them. For #47411. Change-Id: I409f880c8c8f2fe345621401267e4aaabd17124d Reviewed-on: https://go-review.googlesource.com/c/go/+/337354 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/universe.go')
-rw-r--r--src/cmd/compile/internal/types2/universe.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/types2/universe.go b/src/cmd/compile/internal/types2/universe.go
index 0f711a6b68..a3dd4bd0d6 100644
--- a/src/cmd/compile/internal/types2/universe.go
+++ b/src/cmd/compile/internal/types2/universe.go
@@ -88,23 +88,19 @@ func defPredeclaredTypes() {
res := NewVar(nopos, nil, "", Typ[String])
sig := NewSignature(nil, nil, NewTuple(res), false)
err := NewFunc(nopos, nil, "Error", sig)
- ityp := NewInterfaceType([]*Func{err}, nil)
+ ityp := &Interface{obj, []*Func{err}, nil, nil, true, nil}
computeTypeSet(nil, nopos, ityp) // prevent races due to lazy computation of tset
typ := NewNamed(obj, ityp, nil)
sig.recv = NewVar(nopos, nil, "", typ)
def(obj)
}
- // type comparable interface{ ==() }
+ // type comparable interface{ /* type set marked comparable */ }
{
obj := NewTypeName(nopos, nil, "comparable", nil)
obj.setColor(black)
- sig := NewSignature(nil, nil, nil, false)
- eql := NewFunc(nopos, nil, "==", sig)
- ityp := NewInterfaceType([]*Func{eql}, nil)
- computeTypeSet(nil, nopos, ityp) // prevent races due to lazy computation of tset
- typ := NewNamed(obj, ityp, nil)
- sig.recv = NewVar(nopos, nil, "", typ)
+ ityp := &Interface{obj, nil, nil, nil, true, &TypeSet{true, nil, nil}}
+ NewNamed(obj, ityp, nil)
def(obj)
}
}