Fix false positive "Not-null extension receiver of inline function can be made nullable" with operator fun invoke
#KT-25786 Fixed
This commit is contained in:
+1
-1
@@ -66,7 +66,7 @@ class RedundantNotNullExtensionReceiverOfInlineInspection : AbstractKotlinInspec
|
|||||||
}
|
}
|
||||||
is KtThisExpression -> {
|
is KtThisExpression -> {
|
||||||
val expectedType = context[BindingContext.EXPECTED_EXPRESSION_TYPE, it]
|
val expectedType = context[BindingContext.EXPECTED_EXPRESSION_TYPE, it]
|
||||||
expectedType != null && !expectedType.isNullable()
|
it.parent is KtCallExpression || expectedType != null && !expectedType.isNullable()
|
||||||
}
|
}
|
||||||
is KtBinaryExpressionWithTypeRHS -> {
|
is KtBinaryExpressionWithTypeRHS -> {
|
||||||
val type = context[BindingContext.TYPE, it.right]
|
val type = context[BindingContext.TYPE, it.right]
|
||||||
|
|||||||
@@ -48,4 +48,12 @@ inline fun Int.bar(x: Int) = x - this // No problem
|
|||||||
inline fun Int.unary() = -this // No problem
|
inline fun Int.unary() = -this // No problem
|
||||||
inline fun String.indexed(arg: Int) = this[arg] // No problem
|
inline fun String.indexed(arg: Int) = this[arg] // No problem
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
operator fun invoke() = Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun Foo.bar() = this()
|
||||||
|
|
||||||
|
inline fun Foo.bazz() = this.invoke()
|
||||||
|
|
||||||
|
inline fun Foo.bazzz() = invoke()
|
||||||
|
|||||||
Reference in New Issue
Block a user