package com.siyeh.igtest.bugs;

import com.intellij.psi.PsiStatement;
import com.intellij.psi.PsiReferenceExpression;
import com.intellij.psi.PsiElement;

public class CastConflictsWithInstanceofInspection {
    public void foo() {
        Number x = bar();

        System.out.println((Double) x);

        if (x instanceof Float) {
            System.out.println((Double) x);
        }
    }

    private Number bar() {
        return null;
    }

    void method(PsiElement p) {
        if (p instanceof PsiReferenceExpression) {
            PsiStatement stmt = (PsiStatement) p;
            PsiReferenceExpression ref = (PsiReferenceExpression) p;
        } else {
            PsiStatement stmt = (PsiStatement) p;

        }

    }

}

@@ -148,16 +148,253 @@
 ement;%0A%0A
+import javax.swing.JButton;%0Aimport javax.swing.JComponent;%0Aimport java.lang.*;%0Aimport java.lang.Object;%0Aimport java.util.List;%0Aimport java.util.ArrayList;%0Aimport java.util.AbstractList;%0Aimport java.awt.Component;%0Aimport java.awt.Frame;%0A%0A
 public c
@@ -968,10 +968,474 @@
 %0A    %7D%0A%0A
+%0A    boolean foo(Object o) %7B%0A        if (o instanceof List) %7B%0A            return !(o instanceof ArrayList) %7C%7C ((ArrayList)o).get(0) == %22asdf%22;%0A        %7D else if (o instanceof JButton) %7B%0A            if (o instanceof Component) %7B%0A                return ((JComponent)o).isBackgroundSet();%0A            %7D%0A        %7D else if (o instanceof Component) %7B%0A            return o instanceof Frame ? ((Frame)o).isFocusableWindow() : false;%0A        %7D%0A        return false;%0A    %7D%0A%0A
 %7D%0A

test for IDEADEV-8249