Commit 0b9f0908 authored by Luuk van Dijk's avatar Luuk van Dijk

cmd/gc: another special (%hhS) case for method names.

Fixes #2877

R=rsc
CC=golang-dev
https://golang.org/cl/5637047
parent 5efd5624
......@@ -1097,6 +1097,16 @@ exprfmt(Fmt *f, Node *n, int prec)
return fmtprint(f, "%V", &n->val);
case ONAME:
// Special case: explicit name of func (*T) method(...) is turned into pkg.(*T).method,
// but for export, this should be rendered as (*pkg.T).meth.
// These nodes have the special property that they are names with a left OTYPE and a right ONAME.
if(fmtmode == FExp && n->left && n->left->op == OTYPE && n->right && n->right->op == ONAME) {
if(isptr[n->left->type->etype])
return fmtprint(f, "(%T).%hhS", n->left->type, n->right->sym);
else
return fmtprint(f, "%T.%hhS", n->left->type, n->right->sym);
}
//fallthrough
case OPACK:
case ONONAME:
return fmtprint(f, "%S", n->sym);
......
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package one
// Issue 2877
type T struct {
f func(t *T, arg int)
g func(t T, arg int)
}
func (t *T) foo(arg int) {}
func (t T) goo(arg int) {}
func (t *T) F() { t.f = (*T).foo }
func (t *T) G() { t.g = T.goo }
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Use the functions in one.go so that the inlined
// forms get type-checked.
package two
import "./one"
func use() {
var r one.T
r.F()
}
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ignored
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment