Report "use of non-const Kotlin property" also on some assignments

#KT-25536 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-11-23 17:02:41 +03:00
parent 651faa4ab2
commit cb7f7b1de5
4 changed files with 106 additions and 3 deletions
@@ -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
}
@@ -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