aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-06-24 13:48:30 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-06-24 13:48:41 -0700
commite7100adbca33a654101a8fa5779f6d2f675e3675 (patch)
tree62bae5a829cd54e6d8ea3a352e1db1b2a1646689 /src/cmd/compile/internal/noder
parent09a838ad86880150f4e297f7b2dec7c7d116623b (diff)
parent5a1c5b8ae741df2d5c53f328c57a84d85ae6c44a (diff)
downloadgo-e7100adbca33a654101a8fa5779f6d2f675e3675.tar.xz
[dev.unified] all: merge master (5a1c5b8) into dev.unified
Conflicts: - test/run.go Textual conflict adding to the known failures list for the nounified frontend. Merge List: + 2022-06-24 5a1c5b8ae7 cmd/go: add per-package indexing for modules outside mod cache + 2022-06-24 b9c4d94fdb cmd/go/internal/list: update help info with Deprecated field + 2022-06-24 73475ef035 go/types, types2: print qualified object names in cycle errors + 2022-06-24 3e58ef6cc7 go/types, types2: better errors for == when type sets are empty + 2022-06-24 d38f1d13fa doc/go1.19: Linux race detector now requires glibc 2.17 + 2022-06-23 de5329f1de debug/dwarf: handle malformed line table with bad program offset + 2022-06-23 15605ca827 embed: document additional file name restrictions + 2022-06-22 2e773a3894 test: add test that causes gofrontend crash + 2022-06-22 ff17b7d0d4 cmd/compile: don't use dictionary convert to shaped empty interface + 2022-06-22 2a3b467d5f cmd/go: make module .zip files group/world readable + 2022-06-22 bdab4cf47a cmd/go, cmd/link: support failure to create _cgo_import.go + 2022-06-22 aca37d16a5 cmd/go: avoid indexing modules in GOROOT + 2022-06-22 111cdb5848 all: update to current golang.org/x/sys revision + 2022-06-22 4045b1bc3f cmd/compile: fix assert condition in generic method call + 2022-06-22 6bad7e8243 compress/gzip: always close bodyReader in Example_compressingReader + 2022-06-22 606c6c371a encoding/xml: check nil pointer in DecodeElement + 2022-06-22 f571518139 cmd/cgo: dont override declared struct type + 2022-06-22 92c9b81447 net: don't set netGo = true on Windows with no cgo + 2022-06-22 be0b2a393a cmd/trace: add basic documentation to main page + 2022-06-22 b004c739b5 go/types, types2: fix parameter order dependence in type inference + 2022-06-21 f2c7e78592 spec: document operations which accept []byte|string constrained types + 2022-06-21 ab422f2749 runtime/trace: ignore fallback stacks in test + 2022-06-21 66685fb7dd doc/go1.19: use correct link to sync/atomic docs + 2022-06-21 4b236b45d0 runtime: convert flaky semaphore linearity test into benchmark + 2022-06-21 530511bacc cmd/go/internal/modindex: avoid walking modules when not needed + 2022-06-21 c2d373d5d1 cmd/compile: allow 128-bit values to be spilled + 2022-06-21 19ed442807 test: add regress test for #53477 + 2022-06-20 3fcbfb07a8 doc/go1.19: fix HTML validation issues + 2022-06-18 527ace0ffa cmd/compile: skip substituting closures in unsafe builtins arguments + 2022-06-17 ec58e3f327 test: add regress test for #53419 + 2022-06-17 103cc661f1 cmd/go/internal/modfetch: prevent duplicate hashes in go.sum + 2022-06-17 d42a48828f sync: add more notes about Cond behavior + 2022-06-17 9e2f289754 cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID + 2022-06-17 dd2d00f9d5 net: fix flaky *TimeoutMustNotReturn tests + 2022-06-17 6c25ba624f go/token: delete unused File.set field + 2022-06-16 9068c6844d cmd/dist: add package . to 'go test' commands + 2022-06-16 7bad61554e runtime: write much more direct test for semaphore waiter scalability + 2022-06-16 f38a580a51 cmd/go: add more tracing Change-Id: I912c5879165e03f4d7f8ac3ee9241d50fc92a419
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/stencil.go43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go
index 3f12aa3cbd..89869c77d6 100644
--- a/src/cmd/compile/internal/noder/stencil.go
+++ b/src/cmd/compile/internal/noder/stencil.go
@@ -208,9 +208,15 @@ func (g *genInst) scanForGenCalls(decl ir.Node) {
st := g.getInstantiation(gf, targs, true).fun
dictValue, usingSubdict := g.getDictOrSubdict(declInfo, n, gf, targs, true)
- // We have to be using a subdictionary, since this is
- // a generic method call.
- assert(usingSubdict)
+ if hasShapeTypes(targs) {
+ // We have to be using a subdictionary, since this is
+ // a generic method call.
+ assert(usingSubdict)
+ } else {
+ // We should use main dictionary, because the receiver is
+ // an instantiation already, see issue #53406.
+ assert(!usingSubdict)
+ }
// Transform to a function call, by appending the
// dictionary and the receiver to the args.
@@ -721,11 +727,12 @@ func (g *genInst) getInstantiation(nameNode *ir.Name, shapes []*types.Type, isMe
// Struct containing info needed for doing the substitution as we create the
// instantiation of a generic function with specified type arguments.
type subster struct {
- g *genInst
- isMethod bool // If a method is being instantiated
- newf *ir.Func // Func node for the new stenciled function
- ts typecheck.Tsubster
- info *instInfo // Place to put extra info in the instantiation
+ g *genInst
+ isMethod bool // If a method is being instantiated
+ newf *ir.Func // Func node for the new stenciled function
+ ts typecheck.Tsubster
+ info *instInfo // Place to put extra info in the instantiation
+ skipClosure bool // Skip substituting closures
// Map from non-nil, non-ONAME node n to slice of all m, where m.Defn = n
defnMap map[ir.Node][]**ir.Name
@@ -978,7 +985,20 @@ func (subst *subster) node(n ir.Node) ir.Node {
}
}
+ old := subst.skipClosure
+ // For unsafe.{Alignof,Offsetof,Sizeof}, subster will transform them to OLITERAL nodes,
+ // and discard their arguments. However, their children nodes were already process before,
+ // thus if they contain any closure, the closure was still be added to package declarations
+ // queue for processing later. Thus, genInst will fail to generate instantiation for the
+ // closure because of lacking dictionary information, see issue #53390.
+ if call, ok := m.(*ir.CallExpr); ok && call.X.Op() == ir.ONAME {
+ switch call.X.Name().BuiltinOp {
+ case ir.OALIGNOF, ir.OOFFSETOF, ir.OSIZEOF:
+ subst.skipClosure = true
+ }
+ }
ir.EditChildren(m, edit)
+ subst.skipClosure = old
m.SetTypecheck(1)
@@ -1123,6 +1143,9 @@ func (subst *subster) node(n ir.Node) ir.Node {
}
case ir.OCLOSURE:
+ if subst.skipClosure {
+ break
+ }
// We're going to create a new closure from scratch, so clear m
// to avoid using the ir.Copy by accident until we reassign it.
m = nil
@@ -1326,7 +1349,7 @@ func (g *genInst) dictPass(info *instInfo) {
mce := m.(*ir.ConvExpr)
// Note: x's argument is still typed as a type parameter.
// m's argument now has an instantiated type.
- if mce.X.Type().HasShape() || m.Type().HasShape() {
+ if mce.X.Type().HasShape() || (m.Type().HasShape() && !m.Type().IsEmptyInterface()) {
m = convertUsingDictionary(info, info.dictParam, m.Pos(), mce.X, m, m.Type())
}
case ir.ODOTTYPE, ir.ODOTTYPE2:
@@ -1423,7 +1446,7 @@ func findDictType(info *instInfo, t *types.Type) int {
// instantiated node of the CONVIFACE node or XDOT node (for a bound method call) that is causing the
// conversion.
func convertUsingDictionary(info *instInfo, dictParam *ir.Name, pos src.XPos, v ir.Node, in ir.Node, dst *types.Type) ir.Node {
- assert(v.Type().HasShape() || in.Type().HasShape())
+ assert(v.Type().HasShape() || (in.Type().HasShape() && !in.Type().IsEmptyInterface()))
assert(dst.IsInterface())
if v.Type().IsInterface() {