#1302 False Positive: UnusedPrivateField when accessed by inner class
This commit is contained in:
@ -422,6 +422,43 @@ public class InnerPrivateFieldInAnotherInner {
|
|||||||
static class InnerDeclaring {
|
static class InnerDeclaring {
|
||||||
private static int INNER_FIELD;
|
private static int INNER_FIELD;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]]></code>
|
||||||
|
</test-code>
|
||||||
|
<test-code>
|
||||||
|
<description>#1302 False Positive: UnusedPrivateField when accessed by inner class</description>
|
||||||
|
<expected-problems>0</expected-problems>
|
||||||
|
<code><![CDATA[
|
||||||
|
public class UnusedPrivateFieldClass
|
||||||
|
{
|
||||||
|
private int m_number; // UnusedPrivateField incorrectly errors
|
||||||
|
|
||||||
|
public void increment()
|
||||||
|
{
|
||||||
|
m_number++; // Write
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser()
|
||||||
|
{
|
||||||
|
return new User(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class User
|
||||||
|
{
|
||||||
|
private UnusedPrivateFieldClass m_bugTest;
|
||||||
|
private int m_number;
|
||||||
|
|
||||||
|
private User(UnusedPrivateFieldClass bugTest)
|
||||||
|
{
|
||||||
|
m_bugTest = bugTest;
|
||||||
|
m_number = bugTest.m_number; // Read
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return m_bugTest.m_number == m_number;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]]></code>
|
]]></code>
|
||||||
</test-code>
|
</test-code>
|
||||||
|
Reference in New Issue
Block a user