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

Allow generic type parameters to be the same type in method generation #11151

Merged
merged 1 commit into from
May 10, 2016

Conversation

jmarolf
Copy link
Contributor

@jmarolf jmarolf commented May 6, 2016

Previouly we assumed that the type parameters in a method would not be of
the same TypeSymbol when generating a method and put them in a dictionary.
This causes exceptions when attempting to add to the dictionary and the
TypeSymbol is already added as a key. Now we use a list of instead of a
dictionary.

Fixes #10004

@jmarolf
Copy link
Contributor Author

jmarolf commented May 6, 2016

@dotnet/roslyn-ide

@jmarolf jmarolf force-pushed the generate-method-crash-in-generics branch from 34fb562 to 114844e Compare May 6, 2016 23:29
@@ -64,10 +64,10 @@ public static IMethodSymbol RenameTypeParameters(this IMethodSymbol method, ILis
var updatedTypeParameters = RenameTypeParameters(
method.TypeParameters, newNames, typeGenerator);

var mapping = new Dictionary<ITypeSymbol, ITypeSymbol>();
var mapping = new List<KeyValuePair<ITypeSymbol, ITypeSymbol>>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ValueTuple instead of KVP.

@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented May 7, 2016

Easier solution: keep using a dictionary, just use the this[] indexer instead of calling .Add.

@jmarolf jmarolf force-pushed the generate-method-crash-in-generics branch from 114844e to c88f751 Compare May 8, 2016 04:01
Previouly we assumed that the type parameters in a method would not be of
the same TypeSymbol when generating a method and put them in a dictionary.
This causes exceptions when attempting to add to the dictionary and the
TypeSymbol is already added as a key. Now we use a list of instead of a
dictionary.

Fixes dotnet#10004
@jmarolf jmarolf force-pushed the generate-method-crash-in-generics branch from c88f751 to 63e7ce7 Compare May 8, 2016 04:40
@jmarolf
Copy link
Contributor Author

jmarolf commented May 10, 2016

@CyrusNajmabadi review plz

@CyrusNajmabadi
Copy link
Member

👍

@jmarolf jmarolf merged commit 88ffc16 into dotnet:master May 10, 2016
@jmarolf jmarolf deleted the generate-method-crash-in-generics branch July 25, 2017 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants