Search Issue Tracker

By Design

Votes

0

Found in

5.6.0b8

Issue ID

882975

Regression

Yes

Extension method fails to implicitly convert to correct type

Mono

-

Extension method fails to implicitly convert to correct type

To reproduce:
1. Open attached project. Notice the compile error: "Assets/Test.cs(11,14): error CS1929: Type `Floatus' does not contain a member `Testis' and the best extension method overload `Extensions.Testis(this float)' requires an instance of type `float'"

The project has a float with an extension method. It also has a class "Floatus" which has the implicit conversion operator to float. However, calling the extension method on an instance of "Floatus" fails to convert to float correctly

This is a regression - works fine in 5.4.2f2, but fails in 5.5.0f3, 5.6 and up.

The fact that this worked prior to 5.5 was a bug. The same code does not compile in Visual Studio 2015 as well. In general, it is not valid C# code when an implicit conversion is needed to call an extensions method. So the fact that this is an error in 5.5 is a regression, but it is proper behavior.

Add comment

Log in to post comment