Add inspection to detect non-const vals used as Java annotation args

So #KT-20615 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-12-14 12:51:19 +03:00
parent 70b7e5eb68
commit 7358980cbc
16 changed files with 215 additions and 24 deletions
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/FakeJvmFieldConstant.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
@@ -0,0 +1,13 @@
public class JavaUser {
// Dangerous
@Ann(s = KotlinPropertiesKt.importantString)
public void foo() {}
// Also dangerous
@AnnValue(OtherPropertiesKt.notSoImportantString)
public void bar() {}
// Safe
@Ann(s = KotlinPropertiesKt.constantString)
public void baz() {}
}
@@ -0,0 +1,7 @@
annotation class Ann(val s: String)
annotation class AnnValue(val value: String)
@JvmField val importantString = "important"
const val constantString = "constant"