Coffeehouse Post

Single Post Permalink

View Thread: VS14 CTP available
  • User profile image
    Blue Ink

    , babelshift wrote


    I think you're confused.

    The compiler is inferring the type of the generic based on your parameters. It's not "ignoring" it as you seem to suggest.

    There is a possible problem; it all depends on how the new compiler handles it. Assume we have:

    void Foo<T> (T a) {
      // feed a fluffy kitten

    void Foo (int a) { 
      // kill a fluffy kitten

    If we call:


    we are obviously calling the generic version.

    Now, if the compiler told us to remove the generic parameter, it would essentially ignore our choice and we would end up calling the non-generic version, which is semantically different (and not very popular with kittens).

    I expect the compiler to detect that removing the generic parameter would change the overload resolution and not emit the suggestion in this case, but I don't have a spare machine to try it out.

    P.S.: yes, only horrible people write overloads of the same method that are semantically different. I know that. I occasionally also watch naked pointers.