aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/predicates.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-08-24 09:28:43 -0700
committerRobert Griesemer <gri@golang.org>2021-08-25 23:43:40 +0000
commit647bef6c59e201792688d88cdc50ea0c6a68990b (patch)
tree8c3b2630ff77b15dd75d64be1afb5b08b3090cc1 /src/go/types/predicates.go
parent6cf1d5d0fa1049e2910d048ce2b6b5a97fe6edc4 (diff)
downloadgo-647bef6c59e201792688d88cdc50ea0c6a68990b.tar.gz
go-647bef6c59e201792688d88cdc50ea0c6a68990b.zip
go/types: implement NewTypeList and use it instead of composite literals
Also, simplify a bit of code in predicates.go. This is a backport of changes in CL 344615 that were made in addition to the changes of the original CL 343933; it brings go/types in sync with types2. Change-Id: I14cd4d4704d29894d0fbb8d129744d65e332ad22 Reviewed-on: https://go-review.googlesource.com/c/go/+/344570 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/go/types/predicates.go')
-rw-r--r--src/go/types/predicates.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go
index 2f4ef9dace..d4055bb0cc 100644
--- a/src/go/types/predicates.go
+++ b/src/go/types/predicates.go
@@ -312,16 +312,14 @@ func identical(x, y Type, cmpTags bool, p *ifacePair) bool {
return false
}
- if nargs := len(xargs); nargs > 0 {
+ if len(xargs) > 0 {
// Instances are identical if their original type and type arguments
// are identical.
if !Identical(x.orig, y.orig) {
return false
}
- for i := 0; i < nargs; i++ {
- xa := xargs[i]
- ya := yargs[i]
- if !Identical(xa, ya) {
+ for i, xa := range xargs {
+ if !Identical(xa, yargs[i]) {
return false
}
}