Skip to content
Merged
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
22 changes: 13 additions & 9 deletions pkg/analysis/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,8 @@ func extractCallSignature(call *ssa.Call) string {
case *ssa.Builtin:
return fmt.Sprintf("builtin:%s", v.Name())
case *ssa.MakeClosure:
// FIX: Use Safe Type Assertion to avoid panic
if fn, ok := v.Fn.(*ssa.Function); ok && fn != nil {
return fmt.Sprintf("closure:%s", fn.Signature.String())
if sig := extractClosureSignature(v); sig != "" {
return sig
}
}

Expand All @@ -339,9 +338,8 @@ func extractGoSignature(g *ssa.Go) string {
case *ssa.Function:
return extractFunctionSig(v)
case *ssa.MakeClosure:
// FIX: Use Safe Type Assertion
if fn, ok := v.Fn.(*ssa.Function); ok && fn != nil {
return fmt.Sprintf("closure:%s", fn.Signature.String())
if sig := extractClosureSignature(v); sig != "" {
return sig
}
}
// Fallback for dynamic function pointers
Expand All @@ -362,9 +360,8 @@ func extractDeferSignature(d *ssa.Defer) string {
case *ssa.Function:
return extractFunctionSig(v)
case *ssa.MakeClosure:
// FIX: Use Safe Type Assertion
if fn, ok := v.Fn.(*ssa.Function); ok && fn != nil {
return fmt.Sprintf("closure:%s", fn.Signature.String())
if sig := extractClosureSignature(v); sig != "" {
return sig
}
}
if d.Call.Value != nil {
Expand All @@ -373,6 +370,13 @@ func extractDeferSignature(d *ssa.Defer) string {
return "unknown"
}

func extractClosureSignature(v *ssa.MakeClosure) string {
if fn, ok := v.Fn.(*ssa.Function); ok && fn != nil {
return fmt.Sprintf("closure:%s", fn.Signature.String())
}
return ""
}

func extractFunctionSig(fn *ssa.Function) string {
// Fix: Detect anonymous/nested functions to provide stable signatures.
// This handles optimizations where simple closures become plain Functions.
Expand Down
Loading