From 62c968fec22e1de53979952e17497477f3d04713 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Fri, 16 Nov 2012 13:57:23 +0100 Subject: [PATCH] Fix unambiguous check between async Task and Task. Fixes #8414 --- mcs/mcs/ecore.cs | 6 +---- mcs/tests/test-async-41.cs | 30 ++++++++++++++++++++++++ mcs/tests/ver-il-net_4_5.xml | 44 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 mcs/tests/test-async-41.cs diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs index 5f523e4bc7f..745e4224946 100644 --- a/mcs/mcs/ecore.cs +++ b/mcs/mcs/ecore.cs @@ -3822,11 +3822,7 @@ namespace Mono.CSharp { // better conversion is performed between underlying types Y1 and Y2 // if (p.IsGenericTask || q.IsGenericTask) { - if (am.Block.IsAsync) { - if (p.IsGenericTask != q.IsGenericTask) { - return 0; - } - + if (am.Block.IsAsync && p.IsGenericTask && q.IsGenericTask) { q = q.TypeArguments[0]; p = p.TypeArguments[0]; } diff --git a/mcs/tests/test-async-41.cs b/mcs/tests/test-async-41.cs new file mode 100644 index 00000000000..0e8c0fa1e95 --- /dev/null +++ b/mcs/tests/test-async-41.cs @@ -0,0 +1,30 @@ +using System; +using System.Threading; +using System.Threading.Tasks; + +public class AmbiguousGeneric +{ + public async void NestedVoidTestSuccess () + { + await Run2 (async () => await ReturnOne ()); + } + + static Task ReturnOne () + { + return Task.Run (() => 1); + } + + Task Run2 (Func arg) + { + return null; + } + + Task Run2 (Func arg) + { + return null; + } + + public static void Main () + { + } +} \ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_5.xml b/mcs/tests/ver-il-net_4_5.xml index 812a1ac6cb0..cc0f40db316 100644 --- a/mcs/tests/ver-il-net_4_5.xml +++ b/mcs/tests/ver-il-net_4_5.xml @@ -57070,6 +57070,50 @@ + + + + 35 + + + 43 + + + 10 + + + 10 + + + 2 + + + 9 + + + 7 + + + + + 191 + + + 13 + + + 33 + + + + + 162 + + + 13 + + + -- 2.25.1