From 597cd04831bf9487a87f6fba9c30a5dee5e4431f Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 3 Oct 2016 15:13:12 +0300 Subject: [PATCH] KT-13719 'var' can be made 'val' highlighting range with annotation before #KT-13719 Fixed --- .../kotlin/idea/inspections/CanBeValInspection.kt | 5 +++-- .../inspections/canBeVal/inspectionData/expected.xml | 9 +++++++++ idea/testData/inspections/canBeVal/withAnnotation.kt | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 idea/testData/inspections/canBeVal/withAnnotation.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeValInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeValInspection.kt index 08c082df8bb..0f2097ddc43 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeValInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/CanBeValInspection.kt @@ -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, diff --git a/idea/testData/inspections/canBeVal/inspectionData/expected.xml b/idea/testData/inspections/canBeVal/inspectionData/expected.xml index a7684e464ff..5ab6a2c1487 100644 --- a/idea/testData/inspections/canBeVal/inspectionData/expected.xml +++ b/idea/testData/inspections/canBeVal/inspectionData/expected.xml @@ -70,4 +70,13 @@ Local 'var' is never modified and can be declared as 'val' Variable is never modified and can be declared immutable using 'val' + + + withAnnotation.kt + 3 + light_idea_test_case + + Local 'var' is never modified and can be declared as 'val' + Variable is never modified and can be declared immutable using 'val' + diff --git a/idea/testData/inspections/canBeVal/withAnnotation.kt b/idea/testData/inspections/canBeVal/withAnnotation.kt new file mode 100644 index 00000000000..1b4184ca485 --- /dev/null +++ b/idea/testData/inspections/canBeVal/withAnnotation.kt @@ -0,0 +1,5 @@ +fun foo(p: List) { + @Suppress("UNCHECKED_CAST") + var v = p as List + print(v) +} \ No newline at end of file