Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement generic methods on arrays #15

Closed
jp2masa opened this issue Oct 21, 2017 · 1 comment · Fixed by #111
Closed

Implement generic methods on arrays #15

jp2masa opened this issue Oct 21, 2017 · 1 comment · Fixed by #111

Comments

@jp2masa
Copy link
Member

jp2masa commented Oct 21, 2017

From @jp2masa on February 21, 2017 19:19

Currently we don't handle generic methods on arrays.
Example:

IEnumerable<string> xEnumerable;
string[] xArray = new string[] { "a", "b", "c" };
xEnumerable = xArray;
xEnumerable.GetEnumerator();

This code won't work, because Array doesn't have an implementation for this method. Array can be used as ICollection<T>, IEnumerable<T> and IList<T>
The implementations for these interfaces are in System.SZArrayHelper, but the compiler needs an implementation that replaces calls to the generic method on arrays with calls to the methods in SZArrayHelper.

Copied from original issue: CosmosOS/Cosmos#583

@fanoI
Copy link
Contributor

fanoI commented Oct 23, 2017

We can take inspiration from what has been done in CoreRT and implement explicitely Array<T>:
https://github.com/dotnet/corert/blob/master/src/System.Private.CoreLib/src/System/Array.CoreRT.cs#L1428

I think this is the other piece that make this working seamless:
https://github.com/dotnet/corert/blob/master/src/Runtime.Base/src/System/Array.cs#L47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment