This is an archive of the discontinued LLVM Phabricator instance.

[llgo] Use the object's package to mangle method names, rather than the receiver's package
ClosedPublic

Authored by pcc on Dec 15 2014, 6:58 PM.

Details

Summary

If we use the receiver's package, we can end up with identical manglings
for different functions. Consider:

package p
type U struct{}
func (U) f()

package q
import "p"
type T struct { p.U }
func (T) f()

The method set of *T has two synthetic methods named (*T).f(); one forwards to
(T).f(), and the other to (U).f(). Previously, we were distinguishing them
by the receiver's package, and in this case because both methods have the
same receiver, they received the same name.

The methods are correctly distinguished by the package owning the identifier
"f", which is available via f.Object().Pkg().

Diff Detail

Event Timeline

pcc updated this revision to Diff 17316.Dec 15 2014, 6:58 PM
pcc retitled this revision from to [llgo] Use the object's package to mangle method names, rather than the receiver's package.
pcc updated this object.
pcc edited the test plan for this revision. (Show Details)
pcc added a reviewer: axw.
pcc added a subscriber: Unknown Object (MLST).
axw accepted this revision.Dec 15 2014, 9:23 PM
axw edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Dec 15 2014, 9:23 PM
This revision was automatically updated to reflect the committed changes.
irgen/typemap.go