-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
This call in callee.go:
argType := func(i int) types.Type {
return info.TypeOf(n.Results[i]) // inline
}
is inlined to
argType := func(i int) types.Type {
return func(e ast.Expr) types.Type {
if t, ok := info.Types[e]; ok {
return t.Type
}
if id, _ := e.(*ast.Ident); id != nil {
if obj := info.ObjectOf(id); obj != nil {
return obj.Type()
}
}
return nil
}(n.Results[i])
}
I think the only reason is that the final return nil involves a non-trivial conversion from untyped nil to Type(nil), yet TypeOf() is being tailcalled in a Type context, so it's quite safe. It would be nice if this were reduced to this:
argType := func(i int) types.Type {
var e ast.Expr = n.Results[i]
if t, ok := info.Types[e]; ok {
return t.Type
}
if id, _ := e.(*ast.Ident); id != nil {
if obj := info.ObjectOf(id); obj != nil {
return obj.Type()
}
}
return nil
}
(This is a feature request for a [style] optimization, not a bug, in the terms of source-level inliner.)
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.