KT-13719 'var' can be made 'val' highlighting range with annotation before
#KT-13719 Fixed
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun foo(p: List<Any>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
var v = p as List<String>
|
||||
print(v)
|
||||
}
|
||||
Reference in New Issue
Block a user