Nullable function-like property call is prohibited now #KT-8252 Fixed
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
fun bar(doIt: Int.() -> Int) {
|
||||
1.doIt()
|
||||
1<!UNNECESSARY_SAFE_CALL!>?.<!>doIt()
|
||||
val i: Int? = 1
|
||||
i<!UNSAFE_CALL!>.<!>doIt()
|
||||
i?.doIt()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ doIt: kotlin.Int.() -> kotlin.Int): kotlin.Unit
|
||||
@@ -0,0 +1,23 @@
|
||||
class Rule(val apply:() -> Unit)
|
||||
|
||||
fun bar() {}
|
||||
|
||||
fun foo() {
|
||||
val rule: Rule? = Rule { bar() }
|
||||
|
||||
// this compiles and works
|
||||
val apply = rule?.apply
|
||||
if (apply != null) <!DEBUG_INFO_SMARTCAST!>apply<!>()
|
||||
|
||||
// this compiles and works
|
||||
rule?.apply?.invoke()
|
||||
|
||||
// this should be an error
|
||||
rule?.<!UNSAFE_CALL!>apply<!>()
|
||||
|
||||
// these both also ok (with smart cast / unnecessary safe call)
|
||||
if (rule != null) {
|
||||
<!DEBUG_INFO_SMARTCAST!>rule<!>.apply()
|
||||
rule<!UNNECESSARY_SAFE_CALL!>?.<!>apply()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
public fun foo(): kotlin.Unit
|
||||
|
||||
public final class Rule {
|
||||
public constructor Rule(/*0*/ apply: () -> kotlin.Unit)
|
||||
public final val apply: () -> kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user