зеркало из https://github.com/golang/tools.git
internal/refactor/inline: audit for types.Alias safety
Updates golang/go#65294 Change-Id: I14f7d06a0e41799238707b20a88205ae1bfc1ce8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/562036 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> Commit-Queue: Alan Donovan <adonovan@google.com>
This commit is contained in:
Родитель
0d8758985c
Коммит
d64ed6ae4c
|
@ -72,7 +72,7 @@ func escape(info *types.Info, root ast.Node, f func(v *types.Var, escapes bool))
|
|||
if sel, ok := n.Fun.(*ast.SelectorExpr); ok {
|
||||
if seln, ok := info.Selections[sel]; ok &&
|
||||
seln.Kind() == types.MethodVal &&
|
||||
isPointer(seln.Obj().Type().(*types.Signature).Recv().Type()) {
|
||||
isPointer(seln.Obj().Type().Underlying().(*types.Signature).Recv().Type()) {
|
||||
tArg, indirect := effectiveReceiver(seln)
|
||||
if !indirect && !isPointer(tArg) {
|
||||
lvalue(sel.X, true) // &x.f
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/types/typeutil"
|
||||
"golang.org/x/tools/internal/aliases"
|
||||
"golang.org/x/tools/internal/typeparams"
|
||||
)
|
||||
|
||||
|
@ -446,7 +447,7 @@ func (st *falconState) expr(e ast.Expr) (res any) { // = types.TypeAndValue | as
|
|||
// - for an array or *array, use [n]int.
|
||||
// The last two entail progressively stronger index checks.
|
||||
var ct ast.Expr // type syntax for constraint
|
||||
switch t := t.(type) {
|
||||
switch t := aliases.Unalias(t).(type) {
|
||||
case *types.Map:
|
||||
if types.IsInterface(t.Key()) {
|
||||
ct = &ast.MapType{
|
||||
|
|
|
@ -1154,7 +1154,7 @@ func arguments(caller *Caller, calleeDecl *ast.FuncDecl, assign1 func(*types.Var
|
|||
|
||||
// Make * or & explicit.
|
||||
argIsPtr := isPointer(arg.typ)
|
||||
paramIsPtr := isPointer(seln.Obj().Type().(*types.Signature).Recv().Type())
|
||||
paramIsPtr := isPointer(seln.Obj().Type().Underlying().(*types.Signature).Recv().Type())
|
||||
if !argIsPtr && paramIsPtr {
|
||||
// &recv
|
||||
arg.expr = &ast.UnaryExpr{Op: token.AND, X: arg.expr}
|
||||
|
|
|
@ -132,7 +132,7 @@ func indirectSelection(seln *types.Selection) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
tParam := seln.Obj().Type().(*types.Signature).Recv().Type()
|
||||
tParam := seln.Obj().Type().Underlying().(*types.Signature).Recv().Type()
|
||||
return isPointer(tArg) && !isPointer(tParam) // implicit *
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче