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:
Toshiaki Kameyama
2017-09-12 21:54:50 +09:00
committed by Dmitry Jemerov
parent 60c735f2fd
commit 5eb69e0ae4
10 changed files with 117 additions and 4 deletions
@@ -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
}