More accurate handling of Elvis in areParenthesesNecessary #KT-15227 Fixed
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// See KT-15227
|
||||
class My(val local: Boolean)
|
||||
|
||||
class Your(val my: My?, val parent: Any?)
|
||||
|
||||
fun foo(your: Your): Boolean {
|
||||
val my = your.my
|
||||
return <caret>if (my != null) my.local else your.parent != null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// See KT-15227
|
||||
class My(val local: Boolean)
|
||||
|
||||
class Your(val my: My?, val parent: Any?)
|
||||
|
||||
fun foo(your: Your): Boolean {
|
||||
val my = your.my
|
||||
return my?.local ?: (your.parent != null)
|
||||
}
|
||||
@@ -87,4 +87,12 @@
|
||||
<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>comparisonInElse.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/comparisonInElse.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>
|
||||
|
||||
Reference in New Issue
Block a user