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
|
||||
Reference in New Issue
Block a user