Fixed StackOverflow in CanBeValInspection.kt
This commit is contained in:
@@ -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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user