mirror of https://github.com/golang/go.git
cmd/gc: do not confuse unexported methods of same name
Fixes #3146. R=ken2 CC=golang-dev https://golang.org/cl/5756074
This commit is contained in:
parent
105c5fa666
commit
987a580b9f
|
|
@ -1195,10 +1195,17 @@ methodsym(Sym *nsym, Type *t0, int iface)
|
||||||
if(t0->width < types[tptr]->width)
|
if(t0->width < types[tptr]->width)
|
||||||
suffix = "·i";
|
suffix = "·i";
|
||||||
}
|
}
|
||||||
if(t0->sym == S && isptr[t0->etype])
|
if(nsym->pkg != s->pkg && !exportname(nsym->name)) {
|
||||||
p = smprint("(%-hT).%s%s", t0, nsym->name, suffix);
|
if(t0->sym == S && isptr[t0->etype])
|
||||||
else
|
p = smprint("(%-hT).%s.%s%s", t0, nsym->pkg->prefix, nsym->name, suffix);
|
||||||
p = smprint("%-hT.%s%s", t0, nsym->name, suffix);
|
else
|
||||||
|
p = smprint("%-hT.%s.%s%s", t0, nsym->pkg->prefix, nsym->name, suffix);
|
||||||
|
} else {
|
||||||
|
if(t0->sym == S && isptr[t0->etype])
|
||||||
|
p = smprint("(%-hT).%s%s", t0, nsym->name, suffix);
|
||||||
|
else
|
||||||
|
p = smprint("%-hT.%s%s", t0, nsym->name, suffix);
|
||||||
|
}
|
||||||
s = pkglookup(p, s->pkg);
|
s = pkglookup(p, s->pkg);
|
||||||
free(p);
|
free(p);
|
||||||
return s;
|
return s;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && $A.out
|
|
||||||
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
// Test case for embedded method invocation.
|
|
||||||
|
|
||||||
ignored
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// run
|
||||||
|
|
||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
// Copyright 2012 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
@ -9,7 +11,9 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "./lib"
|
import "./bug424.dir"
|
||||||
|
import "reflect"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
type localI interface {
|
type localI interface {
|
||||||
m() string
|
m() string
|
||||||
|
|
@ -53,9 +57,19 @@ func main() {
|
||||||
println("BUG: myT2:", i.m(), "called")
|
println("BUG: myT2:", i.m(), "called")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t3 := new(myT3)
|
||||||
|
if t3.m() != "main.localT.m" {
|
||||||
|
println("BUG: t3:", t3.m(), "called")
|
||||||
|
}
|
||||||
|
|
||||||
i = new(myT3)
|
i = new(myT3)
|
||||||
if i.m() != "main.localT.m" {
|
if i.m() != "main.localT.m" {
|
||||||
|
t := reflect.TypeOf(i)
|
||||||
|
n := t.NumMethod()
|
||||||
|
for j := 0; j < n; j++ {
|
||||||
|
m := t.Method(j)
|
||||||
|
fmt.Printf("#%d: %s.%s %s\n", j, m.PkgPath, m.Name, m.Type)
|
||||||
|
}
|
||||||
println("BUG: myT3:", i.m(), "called")
|
println("BUG: myT3:", i.m(), "called")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue