Update go version
This commit is contained in:
35
vendor/golang.org/x/tools/go/ssa/methods.go
generated
vendored
35
vendor/golang.org/x/tools/go/ssa/methods.go
generated
vendored
@@ -32,8 +32,8 @@ func (prog *Program) MethodValue(sel *types.Selection) *Function {
|
||||
return nil // interface method or type parameter
|
||||
}
|
||||
|
||||
if prog.isParameterized(T) {
|
||||
return nil // generic method
|
||||
if prog.isParameterized(T, sel.Type()) {
|
||||
return nil // method on generic type or generic method
|
||||
}
|
||||
|
||||
if prog.mode&LogSource != 0 {
|
||||
@@ -61,11 +61,11 @@ func (prog *Program) MethodValue(sel *types.Selection) *Function {
|
||||
needsPromotion := len(sel.Index()) > 1
|
||||
needsIndirection := !isPointer(recvType(obj)) && isPointer(T)
|
||||
if needsPromotion || needsIndirection {
|
||||
fn = createWrapper(prog, toSelection(sel))
|
||||
fn = createWrapper(prog, toSelection(sel), nil)
|
||||
fn.buildshared = b.shared()
|
||||
b.enqueue(fn)
|
||||
} else {
|
||||
fn = prog.objectMethod(obj, &b)
|
||||
fn = prog.objectMethod(obj, nil, &b)
|
||||
}
|
||||
if fn.Signature.Recv() == nil {
|
||||
panic(fn)
|
||||
@@ -91,25 +91,22 @@ func (prog *Program) MethodValue(sel *types.Selection) *Function {
|
||||
// objectMethod panics if the function is not a method.
|
||||
//
|
||||
// Acquires prog.objectMethodsMu.
|
||||
func (prog *Program) objectMethod(obj *types.Func, b *builder) *Function {
|
||||
func (prog *Program) objectMethod(obj *types.Func, targs []types.Type, b *builder) *Function {
|
||||
sig := obj.Type().(*types.Signature)
|
||||
if sig.Recv() == nil {
|
||||
panic("not a method: " + obj.String())
|
||||
}
|
||||
|
||||
// Instantiation of generic?
|
||||
if orig := obj.Origin(); orig != obj || len(targs) > 0 {
|
||||
return prog.objectMethod(orig, nil, b).instance(receiverTypeArgs(obj), targs, b)
|
||||
}
|
||||
|
||||
// Belongs to a created package?
|
||||
if fn := prog.FuncValue(obj); fn != nil {
|
||||
return fn
|
||||
}
|
||||
|
||||
// Instantiation of generic?
|
||||
if originObj := obj.Origin(); originObj != obj {
|
||||
origin := prog.objectMethod(originObj, b)
|
||||
assert(origin.typeparams.Len() > 0, "origin is not generic")
|
||||
targs := receiverTypeArgs(obj)
|
||||
return origin.instance(targs, b)
|
||||
}
|
||||
|
||||
// Consult/update cache of methods created from types.Func.
|
||||
prog.objectMethodsMu.Lock()
|
||||
defer prog.objectMethodsMu.Unlock()
|
||||
@@ -170,10 +167,18 @@ func (prog *Program) RuntimeTypes() []types.Type {
|
||||
// eliminates the need to eagerly compute all the element
|
||||
// types during SSA building.
|
||||
var runtimeTypes []types.Type
|
||||
add := func(t types.Type) { runtimeTypes = append(runtimeTypes, t) }
|
||||
var set typeutil.Map // for de-duping identical types
|
||||
for t := range prog.makeInterfaceTypes {
|
||||
typesinternal.ForEachElement(&set, &prog.MethodSets, t, add)
|
||||
typesinternal.ForEachElement(prog.MethodSets.MethodSet, t, func(t types.Type, access bool) bool {
|
||||
if !access {
|
||||
return false // inaccessible to reflection
|
||||
}
|
||||
seen, _ := set.Set(t, true).(bool)
|
||||
if !seen {
|
||||
runtimeTypes = append(runtimeTypes, t)
|
||||
}
|
||||
return seen
|
||||
})
|
||||
}
|
||||
|
||||
return runtimeTypes
|
||||
|
||||
Reference in New Issue
Block a user