Allow to use @TestOnly symbols inside @TestOnly fields (IDEA-148905)

This commit is contained in:
Alexander Zolotov
2015-12-09 14:36:12 +10:00
parent ad0dce975f
commit 7cb3d001e8
6 changed files with 80 additions and 16 deletions
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>A.java</file>
<line>14</line>
<module>testInsideField</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="method" FQNAME="A$2 void run()"/>
<description>Test-only method is called in production code</description>
</problem>
</problems>
@@ -0,0 +1,17 @@
public class A {
@org.jetbrains.annotations.TestOnly
public static final String MY_FIELD = "VALUE";
@org.jetbrains.annotations.TestOnly
public static final Runnable MY_TEST_ONLY_RUNNABLE = new Runnable() {
public void run() {
System.out.println(MY_FIELD);
}
};
public static final Runnable MY_PRODUCTION_RUNNABLE = new Runnable() {
public void run() {
System.out.println(MY_FIELD);
}
};
}
@@ -0,0 +1,10 @@
public class C {
@org.junit.Test
public void foo() {
new Runnable() {
public void run() {
System.out.println(A.MY_FIELD);
}
};
}
}
@@ -0,0 +1,15 @@
public class D {
public static final Runnable MY_RUNNABLE = new Runnable() {
public void run() {
System.out.println(A.MY_FIELD);
}
};
public void test() {
new Runnable() {
public void run() {
System.out.println(A.MY_FIELD);
}
};
}
}