Extractor: explicitly deal with extracting x.(type) in type switches

This commit is contained in:
Owen Mansel-Chan
2024-03-28 16:05:16 +00:00
parent c6f4a204e9
commit 698debfa20

View File

@@ -1010,7 +1010,10 @@ func extractExpr(tw *trap.Writer, expr ast.Expr, parent trap.Label, idx int) {
}
kind = dbscheme.TypeAssertExpr.Index()
extractExpr(tw, expr.X, lbl, 0)
extractExpr(tw, expr.Type, lbl, 1)
// expr.Type can be `nil` if this is the `x.(type)` in a type switch.
if expr.Type != nil {
extractExpr(tw, expr.Type, lbl, 1)
}
case *ast.CallExpr:
if expr == nil {
return