I was looking at this question and i was curious why this deosn\'t compile.
Given this code, can anyone explain why the call to IBase.Test()
doesn\'t re
Okay, the problem is that in the overload resolution process, the compiler finds all applicable candidate methods without checking the generic constraints specified in the method, picks the most specific one, and then checks the generic constraints.
In this case, the generic method is more specific than the non-generic one (as after type parameter substitution, it's effectively a method with an IChildA
parameter instead of an IBase
parameter) - but it then fails the constraints.
I have a blog post explaining this in more detail, and another one using it in a horrible way.