KT-14032 related: if expression to elvis now handles also is and !is checks
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8188bb1e54
commit
121f0ec810
@@ -103,4 +103,20 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>notIsCheck.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/notIsCheck.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>isCheck.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/isCheck.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class My(val x: Int)
|
||||
|
||||
fun foo(arg: Any?): My {
|
||||
return if (<caret>arg is My) arg else My(42)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class My(val x: Int)
|
||||
|
||||
fun foo(arg: Any?): My {
|
||||
return arg as? My ?: My(42)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class My(val x: Int)
|
||||
|
||||
fun foo(arg: Any?): My {
|
||||
return if (<caret>arg !is My) My(42) else arg
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class My(val x: Int)
|
||||
|
||||
fun foo(arg: Any?): My {
|
||||
return arg as? My ?: My(42)
|
||||
}
|
||||
Reference in New Issue
Block a user