Report "use of non-const Kotlin property" also on some assignments
#KT-25536 Fixed
This commit is contained in:
+20
@@ -21,4 +21,24 @@ public class JavaUser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void fau() {
|
||||
byte b1 = KotlinPropertiesKt.importantNumber; // Dangerous
|
||||
byte b2 = KotlinPropertiesKt.constantNumber; // Safe (const)
|
||||
byte b3 = 0 + KotlinPropertiesKt.importantNumber; // Dangerous
|
||||
int b4 = 0 + KotlinPropertiesKt.importantNumber; // Safe (types are the same)
|
||||
b4 += KotlinPropertiesKt.importantNumber; // Safe (modification)
|
||||
long l1 = KotlinPropertiesKt.importantNumber; // Safe (type widening)
|
||||
b2 = KotlinPropertiesKt.importantNumber; // Dangerous
|
||||
b1 = KotlinPropertiesKt.constantNumber; // Safe (const)
|
||||
b3 = (0 + KotlinPropertiesKt.importantNumber); // Dangerous
|
||||
b3 = (byte) (KotlinPropertiesKt.importantNumber); // Safe (explicit cast)
|
||||
b3 = convert(KotlinPropertiesKt.importantNumber); // Safe (explicit cast)
|
||||
}
|
||||
|
||||
public byte convert(int x) {
|
||||
return (byte) x;
|
||||
}
|
||||
|
||||
byte importantNumber = KotlinPropertiesKt.importantNumber; // Also dangerous
|
||||
}
|
||||
Vendored
+5
-1
@@ -4,4 +4,8 @@ annotation class AnnValue(val value: String)
|
||||
|
||||
@JvmField val importantString = "important"
|
||||
|
||||
const val constantString = "constant"
|
||||
const val constantString = "constant"
|
||||
|
||||
@JvmField val importantNumber = 42
|
||||
|
||||
const val constantNumber = 42
|
||||
@@ -26,4 +26,49 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaUser.java</file>
|
||||
<line>26</line>
|
||||
<module>First</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="method" FQNAME="JavaUser void fau()" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaUser.java</file>
|
||||
<line>28</line>
|
||||
<module>First</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="method" FQNAME="JavaUser void fau()" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaUser.java</file>
|
||||
<line>32</line>
|
||||
<module>First</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="method" FQNAME="JavaUser void fau()" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaUser.java</file>
|
||||
<line>34</line>
|
||||
<module>First</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="method" FQNAME="JavaUser void fau()" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>JavaUser.java</file>
|
||||
<line>43</line>
|
||||
<module>First</module>
|
||||
<package><default></package>
|
||||
<entry_point TYPE="field" FQNAME="JavaUser importantNumber" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin non-const property used as Java constant</problem_class>
|
||||
<description>Use of non-const Kotlin property as Java constant is incorrect. Will be forbidden in 1.4</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
Reference in New Issue
Block a user