publicabstract class A {}
public class B : A {}
public class C : A {}
public class D
{
public A GetClass(char className)
{
return className == 'B' ?
new B() :
className == 'C' ? new C() : null;
}
}
R# highlights entire return expression and displays following error message: There is no implicit conversion between 'B' and 'C' which is true but return type is neither 'B' nor 'C' - it 'A' thus error is inappropriate.
Error can be removed by adding manual casting to (A):
publicabstract class A {}
public class B : A {}
public class C : A {}
public class D
{
public A GetClass(char className)
{
return className == 'B' ?
(A)new B() :
className == 'C' ? (A)new C() : null;
}
}
But then R# grays out (A) and warning says 'Type cast is redundant' which is correct. But since removing (A) brings us back error message from above, file never gets green light (it can be either red or orange).
Description
In following code:
publicabstract class A {}
public class B : A {}
public class C : A {}
public class D
{
public A GetClass(char className)
{
return className == 'B' ?
new B() :
className == 'C' ? new C() : null;
}
}
R# highlights entire return expression and displays following error message: There is no implicit conversion between 'B' and 'C' which is true but return type is neither 'B' nor 'C' - it 'A' thus error is inappropriate.
Error can be removed by adding manual casting to (A):
publicabstract class A {}
public class B : A {}
public class C : A {}
public class D
{
public A GetClass(char className)
{
return className == 'B' ?
(A)new B() :
className == 'C' ? (A)new C() : null;
}
}
But then R# grays out (A) and warning says 'Type cast is redundant' which is correct. But since removing (A) brings us back error message from above, file never gets green light (it can be either red or orange).
Re: #25232- Invalid handling of conditional operator. R# always shows error when none
The first piece of code isn't compilable
The second piece of code has no warnings from ReSharper
Eugene Pasynkov - 09 Aug 06 14:53 Re: #25232- Invalid handling of conditional operator. R# always shows error when none
The first piece of code isn't compilable
The second piece of code has no warnings from ReSharper
Build 242/VS2005
The first piece of code isn't compilable
The second piece of code has no warnings from ReSharper
Build 242/VS2005