Fix infinite loop in CanBeValInspection

Obviously there should be 'return' instead of 'continue'
Otherwise the loop will not end

 #KT-11891 Fixed
This commit is contained in:
Denis Zharkov
2016-04-13 17:18:31 +03:00
parent 583733be8d
commit 2f0b052540
3 changed files with 22 additions and 1 deletions
@@ -98,7 +98,7 @@ class CanBeValInspection : AbstractKotlinInspection() {
var instruction = from
while (instruction is InstructionWithNext) {
val next = instruction.next ?: return false
if (next in visited) continue
if (next in visited) return false
if (next in targets) return true
visited.add(next)
instruction = next
@@ -61,4 +61,13 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' can be declared as 'val'</problem_class>
<description>Can be declared as 'val'</description>
</problem>
<problem>
<file>kt11891.kt</file>
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="kt11891.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' can be declared as 'val'</problem_class>
<description>Can be declared as 'val'</description>
</problem>
</problems>
+12
View File
@@ -0,0 +1,12 @@
fun main(args: Array<String?>) {
var a: String?
if (args.size == 1) {
a = args[0]
}
else {
a = args.toString()
}
if (a != null && a.equals("cde")) return
}