Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Generic and non-generic class with the same name cause compiler error

$
0
0

The following classes build fine on Windows (both VS and XS), but cause compilation error on Mac:

        public static class EmptyTask
        {
            public static Task Task { get { return Utils.GetTaskFromResult(0); } }
        }

        public static class EmptyTask<T>
        {
            public static Task<T> Task { get { return _task; } }

            private static readonly Task<T> _task = Utils.GetTaskFromResult(default(T));
        }

The code compiles, but when I try to use it in non-generic manner:

var t = EmptyTask.Task;

then compiler complains about ambiguity between EmptyTask.Task and EmptyTask.Task.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>