Bug 32712 - Incorrect compile error CS4016 when for async function that returns Task<Task>
Summary: Incorrect compile error CS4016 when for async function that returns Task<Task>
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 4.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-08-03 11:25 UTC by jesse.attas
Modified: 2015-08-04 07:02 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description jesse.attas 2015-08-03 11:25:45 UTC
The code snippet below compiles fine in a VS WPF application but generates a compiler error in Xamarin.iOS and Xamarin.Android.

Error:
======
Error CS4016: `AsyncTest.ViewController.ReturnsTaskOfTaskAsync()': The return expression type of async method must be `System.Threading.Tasks.Task' rather than `Task<System.Threading.Tasks.Task>' (CS4016) (AsyncTest)


Code Snippet:
=============
        public async Task ReturnsTaskAsync(Task task)
        {
            await task;
        }

        public async Task<Task> ReturnsTaskOfTaskAsync()
        {
            var t1 = Task.FromResult(ReturnsTaskAsync(null));
            await t1;
            var t2 = Task.FromResult(ReturnsTaskAsync(null));
            return t2;
        }


Tools versions:
===============
Xamarin Studio
Version 5.9.4 (build 5)
Installation UUID: 53fef2ac-96fd-4c07-9e93-cd87aad8d83c
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

Xamarin.Android
Version: 5.1.4.16 (Business Edition)
Android SDK: /Users/JA/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)

Xamarin Android Player
Version: Unknown version
Location: /Applications/Xamarin Android Player.app

Apple Developer Tools
Xcode 6.4 (7720)
Build 6E35b

Xamarin.iOS
Version: 8.10.3.2 (Business Edition)
Hash: 8b265d6
Branch: master
Build date: 2015-06-30 15:19:13-0400

Xamarin.Mac
Not Installed

Build Information
Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

Operating System
Mac OS X 10.10.4
Comment 1 Marek Safar 2015-08-04 07:02:28 UTC
Fixed in master and Mono 4.2

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.


Create a new report for Bug 32712 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments


Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Related Links: