"Use var" fix fails when implicit cast operator exists

Let's say I have this type:

class MyType {

public static implicit operator MySubType(MyType myType);

}

And this code:

MySubType mySubType = MyType;

In this case, there is a "use var" fix for MySubType, which fails, because it doesn't recognize the implicit cast operator from MyType to MySubType:

var mySubType = MyType; // fail: not functional equivalent of original code

The result should be:

var mySubType = (MySubType)MyType; // functional equivalent of original code

1 comment

Hello,

Thank you for reporting! I've filed a bug-report: http://youtrack.jetbrains.net/issue/RSRP-265573
and you're welcome to monitor its status.

Andrey Serebryansky
Senior Support Engineer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Let's say I have this type:

class MyType {
public static implicit operator MySubType(MyType myType);
}
And this code:

MySubType mySubType = MyType;

In this case, there is a "use var" fix for MySubType, which fails,
because it doesn't recognize the implicit cast operator from MyType
to MySubType:

var mySubType = MyType; // fail: not functional equivalent of original
code

The result should be:

var mySubType = (MySubType)MyType; // functional equivalent of
original code

---
Original message URL:
http://devnet.jetbrains.net/message/5303570#5303570



0

Please sign in to leave a comment.