var errors_printer = new SessionReportPrinter ();
var old = bc.Report.SetPrinter (errors_printer);
- ama = new Invocation (ama, args).Resolve (bc);
+
+ //
+ // The expression await t is classified the same way as the expression (t).GetAwaiter().GetResult().
+ //
+ ama = new Invocation (new ParenthesizedExpression (ama, Location.Null), args).Resolve (bc);
bc.Report.SetPrinter (old);
if (errors_printer.ErrorsCount > 0 || !MemberAccess.IsValidDotExpression (ama.Type)) {
--- /dev/null
+using System;
+using System.Threading.Tasks;
+
+class MainClass
+{
+ public static int Main ()
+ {
+ var t = GetSomeStrings (null);
+ try {
+ var s = t.Result;
+ return 1;
+ } catch (AggregateException e) {
+ if (e.InnerException is NullReferenceException)
+ return 0;
+
+ return 2;
+ }
+ }
+
+ public static async Task<string> GetSomeStrings (AsyncStringFactory myFactory)
+ {
+ var res = await myFactory?.GetSomeStringAsync ();
+ return res;
+ }
+}
+
+public class AsyncStringFactory
+{
+ public async Task<string> GetSomeStringAsync ()
+ {
+ await Task.Yield();
+ return "foo";
+ }
+}
\ No newline at end of file
</method>
</type>
</test>
- <test name="test-async-19.cs">
- <type name="C">
- <method name="Void Test(System.Threading.ManualResetEvent)" attrs="145">
- <size>35</size>
- </method>
- <method name="Int32 Main()" attrs="150">
- <size>96</size>
- </method>
- <method name="Void CurrentDomain_UnhandledException(System.Object, System.UnhandledExceptionEventArgs)" attrs="145">
- <size>29</size>
- </method>
- <method name="Void .ctor()" attrs="6278">
- <size>7</size>
- </method>
- <method name="Void .cctor()" attrs="6289">
- <size>12</size>
- </method>
- </type>
- <type name="C+<Test>c__async0">
- <method name="Void MoveNext()" attrs="486">
- <size>227</size>
- </method>
- </type>
- <type name="C+<Test>c__async0+<Test>c__AnonStorey1">
- <method name="Void <>m__0()" attrs="131">
- <size>29</size>
- </method>
- <method name="Void .ctor()" attrs="6278">
- <size>7</size>
- </method>
- </type>
- <type name="C+<Test>c__async0">
- <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
- <size>13</size>
- </method>
- </type>
- </test>
<test name="test-async-20.cs">
<type name="Base">
<method name="Void .ctor()" attrs="6278">
</method>
</type>
</test>
+ <test name="test-async-83.cs">
+ <type name="MainClass">
+ <method name="Int32 Main()" attrs="150">
+ <size>57</size>
+ </method>
+ <method name="System.Threading.Tasks.Task`1[System.String] GetSomeStrings(AsyncStringFactory)" attrs="150">
+ <size>41</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="AsyncStringFactory">
+ <method name="System.Threading.Tasks.Task`1[System.String] GetSomeStringAsync()" attrs="134">
+ <size>33</size>
+ </method>
+ <method name="Void .ctor()" attrs="6278">
+ <size>7</size>
+ </method>
+ </type>
+ <type name="MainClass+<GetSomeStrings>c__async0">
+ <method name="Void MoveNext()" attrs="486">
+ <size>191</size>
+ </method>
+ <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486">
+ <size>13</size>
+ </method>
+ </type>
+ <type name="AsyncStringFactory+<GetSomeStringAsync>c__async0">
+ <method name="Void MoveNext()" attrs="486">
+ <size>171</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">