Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fixes blocking when using function literals #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion compiler/analysis/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type FuncInfo struct {
Blocking map[ast.Node]bool
GotoLabel map[*types.Label]bool
LocalCalls map[*types.Func][][]ast.Node
lFLitCalls map[*FuncInfo][][]ast.Node
ContinueStmts []continueStmt
p *Info
analyzeStack []ast.Node
Expand All @@ -44,6 +45,7 @@ func (info *Info) newFuncInfo() *FuncInfo {
Blocking: make(map[ast.Node]bool),
GotoLabel: make(map[*types.Label]bool),
LocalCalls: make(map[*types.Func][][]ast.Node),
lFLitCalls: make(map[*FuncInfo][][]ast.Node),
}
info.allInfos = append(info.allInfos, funcInfo)
return funcInfo
Expand Down Expand Up @@ -80,6 +82,15 @@ func AnalyzePkg(files []*ast.File, fileSet *token.FileSet, typesInfo *types.Info
done = false
}
}
for fi, calls := range funcInfo.lFLitCalls {
if len(fi.Blocking) != 0 {
for _, call := range calls {
funcInfo.markBlocking(call)
}
delete(funcInfo.lFLitCalls, fi)
done = false
}
}
}
if done {
break
Expand Down Expand Up @@ -186,8 +197,13 @@ func (c *FuncInfo) Visit(node ast.Node) ast.Visitor {
for _, arg := range n.Args {
ast.Walk(c, arg)
}
if len(c.p.FuncLitInfos[f].Blocking) != 0 {
fi := c.p.FuncLitInfos[f]
if len(fi.Blocking) != 0 {
c.markBlocking(c.analyzeStack)
} else {
stack := make([]ast.Node, len(c.analyzeStack))
copy(stack, c.analyzeStack)
c.lFLitCalls[fi] = append(c.lFLitCalls[fi], stack)
}
return nil
default:
Expand Down