KT-20010 'Replace safe access expression with 'if' expression' IDEA Kotlin plugin intention may failed (#1288)
* 'Replace safe access expression with 'if' expression' IDEA Kotlin plugin intention may failed #KT-20010 Fixed * #KT-20010 Fixed
This commit is contained in:
committed by
Dmitry Jemerov
parent
60c735f2fd
commit
5eb69e0ae4
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
foo?<caret>.bar = Bar()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
if (foo != null) foo.bar = Bar()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
foo?<caret>.bar?.baz = 2
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
(if (foo != null) foo.bar else null)?.baz = 2
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
foo?.bar?<caret>.baz = 2
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
val bar = foo?.bar
|
||||
if (bar != null) bar.baz = 2
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
foo?<caret>.bar == null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
var bar: Bar? = null
|
||||
}
|
||||
class Bar {
|
||||
var baz = 1
|
||||
}
|
||||
fun test(foo: Foo?) {
|
||||
(if (foo != null) foo.bar else null) == null
|
||||
}
|
||||
Reference in New Issue
Block a user