bool is_value_type = type.IsStructOrEnum;
VariableReference vr = target as VariableReference;
+ bool prepare_await = ec.HasSet (BuilderContext.Options.AsyncBody) && arguments?.ContainsEmitWithAwait () == true;
+
if (target != null && is_value_type && (vr != null || method == null)) {
+ if (prepare_await) {
+ arguments = arguments.Emit (ec, false, true);
+ prepare_await = false;
+ }
+
target.AddressOf (ec, AddressOp.Store);
} else if (vr != null && vr.IsRef) {
vr.EmitLoad (ec);
}
if (arguments != null) {
- if (ec.HasSet (BuilderContext.Options.AsyncBody) && (arguments.Count > (this is NewInitialize ? 0 : 1)) && arguments.ContainsEmitWithAwait ())
+ if (prepare_await)
arguments = arguments.Emit (ec, false, true);
arguments.Emit (ec);
--- /dev/null
+using System.Threading.Tasks;
+
+public class A
+{
+ public async Task<ValueType> Test1 (int input2)
+ {
+ return new ValueType (await Task.FromResult (12345));
+ }
+
+ public static void Main ()
+ {
+ var a = new A ();
+ a.Test1 (1).Wait ();
+ }
+}
+
+public struct ValueType
+{
+ public ValueType (int field2)
+ {
+ }
+}
</method>
</type>
</test>
+ <test name="test-943.cs">
+ <type name="MyStruct">
+ <method name="Int32 get_X()" attrs="2182">
+ <size>14</size>
+ </method>
+ <method name="Void set_X(Int32)" attrs="2182">
+ <size>8</size>
+ </method>
+ </type>
+ <type name="X">
+ <method name="Int32 Main()" attrs="150">
+ <size>44</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ </test>
<test name="test-95.cs">
<type name="X">
<method name="Int32 Main()" attrs="150">
</method>
</type>
</test>
+ <test name="test-async-92.cs">
+ <type name="A">
+ <method name="System.Threading.Tasks.Task`1[ValueType] Test1(Int32)" attrs="134">
+ <size>33</size>
+ </method>
+ <method name="Void Main()" attrs="150">
+ <size>20</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="ValueType">
+ <method name="Void .ctor(Int32)" attrs="6278">
+ <size>2</size>
+ </method>
+ </type>
+ <type name="A+<Test1>c__async0">
+ <method name="Void MoveNext()" attrs="486">
+ <size>174</size>
+ </method>
+ <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+ <size>13</size>
+ </method>
+ </type>
+ </test>
<test name="test-cls-00.cs">
<type name="CLSCLass_6">
<method name="Void add_Disposed(Delegate)" attrs="2182">