@@ -443,8 +443,8 @@ func (b *builder) addr(fn *Function, e ast.Expr, escaping bool) lvalue {
443
443
return b .addr (fn , e .X , escaping )
444
444
445
445
case * ast.SelectorExpr :
446
- sel , ok := fn .info . Selections [ e ]
447
- if ! ok {
446
+ sel := fn .selection ( e )
447
+ if sel == nil {
448
448
// qualified identifier
449
449
return b .addr (fn , e .Sel , escaping )
450
450
}
@@ -786,8 +786,8 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value {
786
786
return emitLoad (fn , fn .lookup (obj , false )) // var (address)
787
787
788
788
case * ast.SelectorExpr :
789
- sel , ok := fn .info . Selections [ e ]
790
- if ! ok {
789
+ sel := fn .selection ( e )
790
+ if sel == nil {
791
791
// builtin unsafe.{Add,Slice}
792
792
if obj , ok := fn .info .Uses [e .Sel ].(* types.Builtin ); ok {
793
793
return & Builtin {name : obj .Name (), sig : fn .typ (tv .Type ).(* types.Signature )}
@@ -799,28 +799,12 @@ func (b *builder) expr0(fn *Function, e ast.Expr, tv types.TypeAndValue) Value {
799
799
case types .MethodExpr :
800
800
// (*T).f or T.f, the method f from the method-set of type T.
801
801
// The result is a "thunk".
802
-
803
- sel := selection (sel )
804
- if base := fn .typ (sel .Recv ()); base != sel .Recv () {
805
- // instantiate sel as sel.Recv is not equal after substitution.
806
- pkg := fn .declaredPackage ().Pkg
807
- // mv is the instantiated method value.
808
- mv := types .NewMethodSet (base ).Lookup (pkg , sel .Obj ().Name ())
809
- sel = toMethodExpr (mv )
810
- }
811
802
thunk := makeThunk (fn .Prog , sel , b .created )
812
803
return emitConv (fn , thunk , fn .typ (tv .Type ))
813
804
814
805
case types .MethodVal :
815
806
// e.f where e is an expression and f is a method.
816
807
// The result is a "bound".
817
-
818
- if base := fn .typ (sel .Recv ()); base != sel .Recv () {
819
- // instantiate sel as sel.Recv is not equal after substitution.
820
- pkg := fn .declaredPackage ().Pkg
821
- // mv is the instantiated method value.
822
- sel = types .NewMethodSet (base ).Lookup (pkg , sel .Obj ().Name ())
823
- }
824
808
obj := sel .Obj ().(* types.Func )
825
809
rt := fn .typ (recvType (obj ))
826
810
wantAddr := isPointer (rt )
@@ -939,7 +923,7 @@ func (b *builder) stmtList(fn *Function, list []ast.Stmt) {
939
923
// must thus be addressable.
940
924
//
941
925
// escaping is defined as per builder.addr().
942
- func (b * builder ) receiver (fn * Function , e ast.Expr , wantAddr , escaping bool , sel * types. Selection ) Value {
926
+ func (b * builder ) receiver (fn * Function , e ast.Expr , wantAddr , escaping bool , sel * selection ) Value {
943
927
var v Value
944
928
if wantAddr && ! sel .Indirect () && ! isPointer (fn .typeOf (e )) {
945
929
v = b .addr (fn , e , escaping ).address (fn )
@@ -964,15 +948,9 @@ func (b *builder) setCallFunc(fn *Function, e *ast.CallExpr, c *CallCommon) {
964
948
965
949
// Is this a method call?
966
950
if selector , ok := unparen (e .Fun ).(* ast.SelectorExpr ); ok {
967
- sel , ok := fn .info . Selections [ selector ]
968
- if ok && sel .Kind () == types .MethodVal {
951
+ sel := fn .selection ( selector )
952
+ if sel != nil && sel .Kind () == types .MethodVal {
969
953
obj := sel .Obj ().(* types.Func )
970
- if recv := fn .typ (sel .Recv ()); recv != sel .Recv () {
971
- // adjust obj if the sel.Recv() changed during monomorphization.
972
- pkg := fn .declaredPackage ().Pkg
973
- method , _ , _ := types .LookupFieldOrMethod (recv , true , pkg , sel .Obj ().Name ())
974
- obj = method .(* types.Func )
975
- }
976
954
recv := recvType (obj )
977
955
978
956
wantAddr := isPointer (recv )
0 commit comments