declaration-site extension methods possibly dangerous

Rémi Forax forax at univ-mlv.fr
Fri Dec 11 06:12:47 PST 2009


Fatih Coskun a écrit :
> declaration-site extension methods can be easily confused with abstract 
> methods of an interface. I can imagine many developers trying to 
> override extension methods in their subclasses in order to provide 
> different implementations. But this will not work. 

Right

> declaration-site 
> extension methods cannot be overriden, they are hidden instead.

Why ?, The proposal doesn't say anything about that.

>  This 
> means, that the extension method will always be invoked, if the static 
> type of a variable is the interface type, although the dynamic object 
> type may have hidden the extension method with an own implementation. 
> This will lead to much confusion. Note, that use-site extension method 
> do not have this problem.
>   

I don't understand why use-site extension don't suffer from the same 
disease.

Rémi



More information about the lambda-dev mailing list