Prohibit expressions of Result type as left operands of ?./!!/?:
#KT-26659 In Progress
This commit is contained in:
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
fun <T> id(x: T): T = x
|
||||
|
||||
private val asFun: () -> Result<Int>? = TODO()
|
||||
private val Int.intResult: Result<Int>?
|
||||
get() = null
|
||||
|
||||
fun returnInt(): Int? = 0
|
||||
|
||||
|
||||
fun nullableOperators(r1: Result<Int>?, b: Boolean) {
|
||||
if (b) {
|
||||
r1<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>!!<!>
|
||||
asFun()<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>!!<!>
|
||||
returnInt()?.intResult<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>!!<!>.toString()
|
||||
}
|
||||
|
||||
if (b) {
|
||||
id(r1)<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>!!<!>
|
||||
}
|
||||
|
||||
if (b) {
|
||||
r1<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?.<!>toString()
|
||||
returnInt()?.intResult<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?.<!>toString()
|
||||
asFun()<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?.<!>toString()
|
||||
id(r1)<!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?.<!>toString()
|
||||
}
|
||||
|
||||
if (b) {
|
||||
r1 <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> 0
|
||||
r1 <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> r1
|
||||
asFun() <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> r1 <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> 0
|
||||
id(asFun()) <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> 0
|
||||
|
||||
returnInt() ?: returnInt() ?: asFun() <!RESULT_CLASS_WITH_NULLABLE_OPERATOR!>?:<!> 0
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package
|
||||
|
||||
private val asFun: () -> kotlin.Result<kotlin.Int>?
|
||||
private val kotlin.Int.intResult: kotlin.Result<kotlin.Int>?
|
||||
public fun </*0*/ T> id(/*0*/ x: T): T
|
||||
public fun nullableOperators(/*0*/ r1: kotlin.Result<kotlin.Int>?, /*1*/ b: kotlin.Boolean): kotlin.Unit
|
||||
public fun returnInt(): kotlin.Int?
|
||||
Reference in New Issue
Block a user