So I have a tree class:
public class Tree<T> : IEnumerable where T : IComparable<T>
{
private Node<T> root = null;
...
private class Node<T> : IEnumerable<T> where T : IComparable<T>
{
private Node<T> left, right;
...
}
}
It works fine, but I get the compiler warning: Type parameter 'T' has the same name as the type parameter from outer type 'Tree<T>'
Well, of course it's the same name, they should be the same type. (In fact, since the Node
class is private and thus can never be accessed outside of the Tree
class, they are guaranteed to be the same type. Is this compiler warning just BS which I can safely ignore? Or is there some good reason why I should give the inner class a different generic name (other than just to make the warning go away)?
(I saw this question, which is about the warning itself, but this is clearly a different scenario. The types are guaranteed to be the same, as Node
's are only created and accessed within the context of Tree
, so there's no chance of confusion.)