mirror of
https://github.com/golang/go
synced 2024-11-24 21:20:05 -07:00
parent
3fc327b33b
commit
81728cf06d
@ -290,12 +290,13 @@ inlnode(Node **np)
|
||||
{
|
||||
Node *n;
|
||||
NodeList *l;
|
||||
int lno;
|
||||
|
||||
if(*np == nil)
|
||||
return;
|
||||
|
||||
n = *np;
|
||||
|
||||
|
||||
switch(n->op) {
|
||||
case ODEFER:
|
||||
case OPROC:
|
||||
@ -312,6 +313,8 @@ inlnode(Node **np)
|
||||
return;
|
||||
}
|
||||
|
||||
lno = setlineno(n);
|
||||
|
||||
inlnodelist(n->ninit);
|
||||
for(l=n->ninit; l; l=l->next)
|
||||
if(l->n->op == OINLCALL)
|
||||
@ -431,6 +434,8 @@ inlnode(Node **np)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
lineno = lno;
|
||||
}
|
||||
|
||||
// if *np is a call, and fn is a function with an inlinable body, substitute *np with an OINLCALL.
|
||||
@ -495,20 +500,19 @@ mkinlcall(Node **np, Node *fn)
|
||||
as = N;
|
||||
if(fn->type->thistuple) {
|
||||
t = getthisx(fn->type)->type;
|
||||
|
||||
if(t != T && t->nname != N && !t->nname->inlvar)
|
||||
if(t != T && t->nname != N && !isblank(t->nname) && !t->nname->inlvar)
|
||||
fatal("missing inlvar for %N\n", t->nname);
|
||||
|
||||
if(n->left->op == ODOTMETH) {
|
||||
if (!n->left->left)
|
||||
fatal("method call without receiver: %+N", n);
|
||||
if(t != T && t->nname)
|
||||
if(t != T && t->nname != N && !isblank(t->nname))
|
||||
as = nod(OAS, t->nname->inlvar, n->left->left);
|
||||
// else if !ONAME add to init anyway?
|
||||
} else { // non-method call to method
|
||||
if (!n->list)
|
||||
fatal("non-method call to method without first arg: %+N", n);
|
||||
if(t != T && t->nname)
|
||||
if(t != T && t->nname != N && !isblank(t->nname))
|
||||
as = nod(OAS, t->nname->inlvar, n->list->n);
|
||||
}
|
||||
|
||||
|
@ -13,3 +13,7 @@ func F1(T *T) bool { return T == nil }
|
||||
|
||||
// Issue 2682.
|
||||
func F2(c chan int) bool { return c == (<-chan int)(nil) }
|
||||
|
||||
// Call of inlined method with blank receiver.
|
||||
func (_ *T) M() int { return 1 }
|
||||
func (t *T) MM() int { return t.M() }
|
||||
|
@ -12,5 +12,9 @@ import "./one"
|
||||
func use() {
|
||||
one.F1(nil)
|
||||
one.F2(nil)
|
||||
|
||||
var t *one.T
|
||||
t.M()
|
||||
t.MM()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user