KT-13719 'var' can be made 'val' highlighting range with annotation before

#KT-13719 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-10-03 15:13:12 +03:00
parent 8d48b0d2a0
commit 597cd04831
3 changed files with 17 additions and 2 deletions
@@ -127,9 +127,10 @@ class CanBeValInspection : AbstractKotlinInspection() {
}
private fun reportCanBeVal(declaration: KtValVarKeywordOwner) {
val keyword = declaration.valOrVarKeyword!!
val problemDescriptor = holder.manager.createProblemDescriptor(
declaration,
declaration.valOrVarKeyword!!,
keyword,
keyword,
"Variable is never modified and can be declared immutable using 'val'",
ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
isOnTheFly,
@@ -70,4 +70,13 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' is never modified and can be declared as 'val'</problem_class>
<description>Variable is never modified and can be declared immutable using 'val'</description>
</problem>
<problem>
<file>withAnnotation.kt</file>
<line>3</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="withAnnotation.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' is never modified and can be declared as 'val'</problem_class>
<description>Variable is never modified and can be declared immutable using 'val'</description>
</problem>
</problems>
+5
View File
@@ -0,0 +1,5 @@
fun foo(p: List<Any>) {
@Suppress("UNCHECKED_CAST")
var v = p as List<String>
print(v)
}