Fixed StackOverflow in CanBeValInspection.kt

This commit is contained in:
Valentin Kipyatkov
2016-04-07 11:31:46 +03:00
parent 22a4bbe1aa
commit a9fe999e0e
3 changed files with 16 additions and 1 deletions
@@ -108,7 +108,7 @@ class CanBeValInspection : AbstractKotlinInspection() {
if (next in visited) continue if (next in visited) continue
if (next in targets) return true if (next in targets) return true
visited.add(next) visited.add(next)
if (canReach(next, targets)) return true if (canReach(next, targets, visited)) return true
} }
return false return false
} }
@@ -52,4 +52,13 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' can be declared as 'val'</problem_class> <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Local 'var' can be declared as 'val'</problem_class>
<description>Can be declared as 'val'</description> <description>Can be declared as 'val'</description>
</problem> </problem>
<problem>
<file>stackOverflowBug.kt</file>
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="stackOverflowBug.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> </problems>
@@ -0,0 +1,6 @@
fun foo() {
var a: Int
a = 1
for (i in 1..10)
print(i)
}