History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-25232
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Blocker Blocker
Assignee: Eugene Pasynkov
Reporter: Boris Kartamyshev
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ReSharper

Invalid handling of conditional operator. R# always shows error when none exists

Created: 06 Aug 06 17:28   Updated: 09 Sep 06 13:33
Component/s: None
Fix Version/s: 2.0.1
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 240
Old URL: http://www.intellij.net/tracker/resharper/viewSCR?publicId=25232


 Description  « Hide
In following code:
public abstract 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):

public abstract 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).



 All   Comments   Work Log   Change History      Sort Order:
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