compiler: use correct value type in 2-case select send

In the channel-send case, the value to be sent may needs an
(implicit) type conversion to the channel element type. This CL
ensures that we use the correct value type for the send.

Fixes golang/go#33235.

Change-Id: I565147a617ed8a1337d2c8251d98a6779f2812c7
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/187177
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/go/statements.cc b/go/statements.cc
index 27c4b95..6d9c0eb 100644
--- a/go/statements.cc
+++ b/go/statements.cc
@@ -5880,6 +5880,7 @@
      : this->clauses_->at(1));
   Location loc = this->location();
   Expression* chan = chancase.channel();
+  Type* valtype = chan->type()->channel_type()->element_type();
 
   Temporary_statement* chantmp = Statement::make_temporary(NULL, chan, loc);
   b->add_statement(chantmp);
@@ -5891,7 +5892,8 @@
     {
       // if selectnbsend(chan, &val) { body } else { default body }
 
-      Temporary_statement* ts = Statement::make_temporary(NULL, chancase.val(), loc);
+      Temporary_statement* ts =
+        Statement::make_temporary(valtype, chancase.val(), loc);
       // Tell the escape analysis that the value escapes, as it may be sent
       // to a channel.
       ts->set_value_escapes();
@@ -5904,7 +5906,6 @@
     }
   else
     {
-      Type* valtype = chan->type()->channel_type()->element_type();
       Temporary_statement* ts = Statement::make_temporary(valtype, NULL, loc);
       b->add_statement(ts);