aboutsummaryrefslogtreecommitdiffstats
path: root/capturedrefrace.go
diff options
context:
space:
mode:
Diffstat (limited to 'capturedrefrace.go')
-rw-r--r--capturedrefrace.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/capturedrefrace.go b/capturedrefrace.go
index afb104c..54c5c04 100644
--- a/capturedrefrace.go
+++ b/capturedrefrace.go
@@ -94,6 +94,26 @@ func run(pass *analysis.Pass) (interface{}, error) {
obj := pass.TypesInfo.Uses[funcIdent]
fmt.Printf("funcobj-fromtypesinfo: %#v\n", obj)
fmt.Printf("funcobj-fromtypesinfo-type: %#v\n", obj.Type())
+ def := pass.TypesInfo.Defs[funcIdent]
+ fmt.Printf("func def: %#v\n", def)
+
+ obj2 := pass.TypesInfo.ObjectOf(funcIdent)
+ fmt.Printf("obj2: %#v\n", obj2)
+
+ fmt.Printf("obj-parent: %#v\n", obj.Parent())
+
+ fmt.Printf("parent lookup: %#v\n", obj.Parent().Lookup(obj.Name()))
+ // TODO: How to get the scope of the closure?
+
+ das, ok := funcIdent.Obj.Decl.(*ast.AssignStmt)
+ if ok {
+ for _, expr := range das.Rhs {
+ fl, ok := expr.(*ast.FuncLit)
+ if ok {
+ fmt.Printf("funclit: %#v\n", fl)
+ }
+ }
+ }
}
// Look for a function literal after the `go` statement.