Introduce subject to when: suggest for qualified, not for obj / constant
#KT-18772 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2cde0a800a
commit
fdf9acfb6a
@@ -0,0 +1,13 @@
|
||||
import Platform.JvmPlatform
|
||||
|
||||
sealed class Platform {
|
||||
object JvmPlatform : Platform()
|
||||
class Another(val name: String) : Platform()
|
||||
}
|
||||
|
||||
class ModuleInfo(val platform: Platform)
|
||||
|
||||
fun foo(moduleInfo: ModuleInfo) = <caret>when {
|
||||
moduleInfo.platform == JvmPlatform -> 1
|
||||
else -> 0
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import Platform.JvmPlatform
|
||||
|
||||
sealed class Platform {
|
||||
object JvmPlatform : Platform()
|
||||
class Another(val name: String) : Platform()
|
||||
}
|
||||
|
||||
class ModuleInfo(val platform: Platform)
|
||||
|
||||
fun foo(moduleInfo: ModuleInfo) = <caret>when (moduleInfo.platform) {
|
||||
JvmPlatform -> 1
|
||||
else -> 0
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import Platform.JvmPlatform
|
||||
|
||||
sealed class Platform {
|
||||
object JvmPlatform : Platform()
|
||||
class Another(val name: String) : Platform()
|
||||
}
|
||||
|
||||
class ModuleInfo(val platform: Platform)
|
||||
|
||||
fun foo(moduleInfo: ModuleInfo) = <caret>when {
|
||||
JvmPlatform == moduleInfo.platform -> 1
|
||||
else -> 0
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import Platform.JvmPlatform
|
||||
|
||||
sealed class Platform {
|
||||
object JvmPlatform : Platform()
|
||||
class Another(val name: String) : Platform()
|
||||
}
|
||||
|
||||
class ModuleInfo(val platform: Platform)
|
||||
|
||||
fun foo(moduleInfo: ModuleInfo) = <caret>when (moduleInfo.platform) {
|
||||
JvmPlatform -> 1
|
||||
else -> 0
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
fun test(foo: Foo): Int {
|
||||
return <caret>when {
|
||||
foo.bar == 1 -> 10
|
||||
foo.bar == 2 -> 20
|
||||
else -> 30
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
fun test(foo: Foo): Int {
|
||||
return <caret>when (foo.bar) {
|
||||
1 -> 10
|
||||
2 -> 20
|
||||
else -> 30
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
const val A = 1
|
||||
const val B = 2
|
||||
|
||||
fun test(foo: Foo): Int {
|
||||
return <caret>when {
|
||||
A == foo.bar -> 10
|
||||
B == foo.bar -> 20
|
||||
else -> 30
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
class Foo {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
const val A = 1
|
||||
const val B = 2
|
||||
|
||||
fun test(foo: Foo): Int {
|
||||
return <caret>when (foo.bar) {
|
||||
A -> 10
|
||||
B -> 20
|
||||
else -> 30
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user