aboutsummaryrefslogtreecommitdiff
path: root/src/go
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2021-08-26 15:04:40 -0400
committerMichael Matloob <matloob@golang.org>2021-08-26 15:04:42 -0400
commitde83ef67acaaf5c2ce12dd831e8d3d04f02a6fc9 (patch)
treede1e9db916cb810d3360137a7b5ead7c00f7bce5 /src/go
parentde23549a3967ade982d848a5b6ae3cb3fa0dba45 (diff)
parent5e6a7e9b860d7c8f589eec3c123469ea8071689f (diff)
downloadgo-de83ef67acaaf5c2ce12dd831e8d3d04f02a6fc9.tar.gz
go-de83ef67acaaf5c2ce12dd831e8d3d04f02a6fc9.zip
[dev.cmdgo] all: merge master (5e6a7e9) into dev.cmdgo
Merge List: + 2021-08-26 5e6a7e9b86 embed: remove reference to global variables in docs + 2021-08-26 166b691b65 cmd/compile/internal/types2: remove need for instance (struct) + 2021-08-26 d6bdae33e9 cmd/compile/internal/types2: address some TODOs (cleanup) + 2021-08-26 770df2e18d crypto/tls: fix typo in PreferServerCipherSuites comment + 2021-08-26 a6ff433d6a cmd/go: pass -gcflags after other flags generated by the go command + 2021-08-25 4f2620285d cmd/compile/internal/types2: fix type set printing and add test + 2021-08-25 0ac64f6d70 cmd/compile/internal/types2: rename IsMethodSet to IsConstraint (cleanup) + 2021-08-25 4068fb6c21 cmd/compile: always accept 1.18 syntax but complain if not 1.18 + 2021-08-25 bf0bc4122f go/types, types2: don't re-evaluate context string for each function argument (optimization) + 2021-08-25 4158e88f64 cmd/compile/internal/syntax: fix position of type parameter field + 2021-08-25 647bef6c59 go/types: implement NewTypeList and use it instead of composite literals + 2021-08-25 6cf1d5d0fa cmd/compile: generic SSA rules for simplifying 2 and 3 operand integer arithmetic expressions + 2021-08-25 5baf60d472 bytes, strings: optimize Trim for single byte cutsets + 2021-08-25 3d667671ad cmd/compile: fix function contains no TParam in generic function + 2021-08-25 4f2ebfe34b cmd/compile: allow embed into any byte slice type + 2021-08-25 d2f002cb39 time/format: avoid growslice in time.String()/time.GoString() + 2021-08-25 08d4cc20ca cmd/compile: fix stencil call expression. + 2021-08-25 099b819085 cmd/compile: fix CheckSize() calculation for -G=3 and stencils + 2021-08-25 e1fcf8857e test: add test that caused gofrontend compiler crash + 2021-08-25 d37b8dedf7 test: add test case that gofrontend miscompiled + 2021-08-25 41b99dab0f os/user: don't skip TestLookupGroup if supported + 2021-08-25 de1c934b97 cmd/compile: fix checkptr false positive for (*[Big]T)(ptr)[:n:n] pattern + 2021-08-24 54cdef1f10 reflect: add MapIter.SetKey and MapIter.SetValue + 2021-08-24 5d863f89fe cmd/compile: simplify bad conversion check Change-Id: I29ab927f0e47f44d82f9307c642900f75f4f678f
Diffstat (limited to 'src/go')
-rw-r--r--src/go/types/call.go7
-rw-r--r--src/go/types/check.go2
-rw-r--r--src/go/types/instantiate.go2
-rw-r--r--src/go/types/predicates.go8
-rw-r--r--src/go/types/subst.go2
-rw-r--r--src/go/types/typelists.go8
6 files changed, 19 insertions, 10 deletions
diff --git a/src/go/types/call.go b/src/go/types/call.go
index 87eeef444b..fdecafb781 100644
--- a/src/go/types/call.go
+++ b/src/go/types/call.go
@@ -347,8 +347,11 @@ func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type
}
// check arguments
- for i, a := range args {
- check.assignment(a, sigParams.vars[i].typ, check.sprintf("argument to %s", call.Fun))
+ if len(args) > 0 {
+ context := check.sprintf("argument to %s", call.Fun)
+ for i, a := range args {
+ check.assignment(a, sigParams.vars[i].typ, context)
+ }
}
return
diff --git a/src/go/types/check.go b/src/go/types/check.go
index 909bf8d52d..ab3a388e9f 100644
--- a/src/go/types/check.go
+++ b/src/go/types/check.go
@@ -407,7 +407,7 @@ func (check *Checker) recordInferred(call ast.Expr, targs []Type, sig *Signature
assert(call != nil)
assert(sig != nil)
if m := check.Inferred; m != nil {
- m[call] = Inferred{&TypeList{targs}, sig}
+ m[call] = Inferred{NewTypeList(targs), sig}
}
}
diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go
index 3ee09b7e84..5f691d5246 100644
--- a/src/go/types/instantiate.go
+++ b/src/go/types/instantiate.go
@@ -131,7 +131,7 @@ func (check *Checker) instance(pos token.Pos, typ Type, targs []Type) (res Type)
tname := NewTypeName(pos, t.obj.pkg, t.obj.name, nil)
named := check.newNamed(tname, t, nil, nil, nil) // methods and tparams are set when named is loaded
- named.targs = &TypeList{targs}
+ named.targs = NewTypeList(targs)
named.instance = &instance{pos}
if check != nil {
check.typMap[h] = named
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
}
}
diff --git a/src/go/types/subst.go b/src/go/types/subst.go
index 8b8d6fb82a..1c53cdaf2c 100644
--- a/src/go/types/subst.go
+++ b/src/go/types/subst.go
@@ -233,7 +233,7 @@ func (subst *subster) typ(typ Type) Type {
// It's ok to provide a nil *Checker because the newly created type
// doesn't need to be (lazily) expanded; it's expanded below.
named := (*Checker)(nil).newNamed(tname, t.orig, nil, t.tparams, t.methods) // t is loaded, so tparams and methods are available
- named.targs = &TypeList{newTArgs}
+ named.targs = NewTypeList(newTArgs)
subst.typMap[h] = named
t.expand(subst.typMap) // must happen after typMap update to avoid infinite recursion
diff --git a/src/go/types/typelists.go b/src/go/types/typelists.go
index a8181404bf..ef8ea1f32b 100644
--- a/src/go/types/typelists.go
+++ b/src/go/types/typelists.go
@@ -27,6 +27,14 @@ func (l *TParamList) list() []*TypeParam {
// TypeList holds a list of types.
type TypeList struct{ types []Type }
+// NewTypeList returns a new TypeList with the types in list.
+func NewTypeList(list []Type) *TypeList {
+ if len(list) == 0 {
+ return nil
+ }
+ return &TypeList{list}
+}
+
// Len returns the number of types in the list.
// It is safe to call on a nil receiver.
func (l *TypeList) Len() int { return len(l.list()) }