(1.1 only) Var can be val: correct handling of delegated local variables #KT-14409 Fixed
This commit is contained in:
@@ -79,4 +79,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>withReadOnlyDelegate.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="withReadOnlyDelegate.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,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
var s: String by Delegates.notNull()
|
||||
s = ""
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
var s: String by lazy { "Hello!" }
|
||||
s.hashCode()
|
||||
}
|
||||
Reference in New Issue
Block a user