forked from mono/mono
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix calling await on base expressions
- Loading branch information
1 parent
f97e03f
commit 989100d
Showing
3 changed files
with
129 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
class A | ||
{ | ||
public virtual Task<int> Foo (int value) | ||
{ | ||
return Task.FromResult (value); | ||
} | ||
|
||
public virtual Task<int> Prop { get; set; } | ||
} | ||
|
||
class B : A | ||
{ | ||
public override Task<int> Prop { | ||
get { | ||
throw new ApplicationException (); | ||
} | ||
set { | ||
throw new ApplicationException (); | ||
} | ||
} | ||
|
||
public override async Task<int> Foo (int value) | ||
{ | ||
return await base.Foo (value) + 1; | ||
} | ||
|
||
public async Task<int> Foo2 (int value) | ||
{ | ||
base.Prop = Task.FromResult (value); | ||
return await base.Prop; | ||
} | ||
} | ||
|
||
class Program | ||
{ | ||
static int Main() | ||
{ | ||
var b = new B (); | ||
if (b.Foo (3).Result != 4) | ||
return 1; | ||
|
||
if (b.Foo2 (5).Result != 5) | ||
return 2; | ||
|
||
Console.WriteLine("ok"); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters