diff mbox

Go patch committed: Use receiver type name in type descriptor name

Message ID CAOyqgcXtjsJ1+kqqZio9mvB7xgPfUiQtPMK2E7E2ra6FNYdLdQ@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 6, 2015, 2:27 a.m. UTC
If different named types have methods with the same name, and the
methods with the same name define nested types with the same name, the
type descriptors for those nested types could collide at link time.
This patch by Chris Manghane fixes the problem.  This is issue 33 in
the gofrontend issue tracker.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r 3196a4d08deb go/types.cc
--- a/go/types.cc	Mon Jan 05 08:12:31 2015 -0800
+++ b/go/types.cc	Mon Jan 05 18:23:58 2015 -0800
@@ -1296,6 +1296,14 @@ 
       ret.append(1, '.');
       if (in_function != NULL)
 	{
+	  const Typed_identifier* rcvr =
+	    in_function->func_value()->type()->receiver();
+	  if (rcvr != NULL)
+	    {
+	      Named_type* rcvr_type = rcvr->type()->deref()->named_type();
+	      ret.append(Gogo::unpack_hidden_name(rcvr_type->name()));
+	      ret.append(1, '.');
+	    }
 	  ret.append(Gogo::unpack_hidden_name(in_function->name()));
 	  ret.append(1, '.');
 	  if (index > 0)
@@ -9170,6 +9178,14 @@ 
       name.append(1, '.');
       if (this->in_function_ != NULL)
 	{
+	  const Typed_identifier* rcvr =
+	    this->in_function_->func_value()->type()->receiver();
+	  if (rcvr != NULL)
+	    {
+	      Named_type* rcvr_type = rcvr->type()->deref()->named_type();
+	      name.append(Gogo::unpack_hidden_name(rcvr_type->name()));
+	      name.append(1, '.');
+	    }
 	  name.append(Gogo::unpack_hidden_name(this->in_function_->name()));
 	  name.append(1, '$');
 	  if (this->in_function_index_ > 0)