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:
Dmitry Gridin
2019-06-18 11:35:40 +07:00
parent eae1813ead
commit 7040639c38
2 changed files with 9 additions and 1 deletions
@@ -66,7 +66,7 @@ class RedundantNotNullExtensionReceiverOfInlineInspection : AbstractKotlinInspec
}
is KtThisExpression -> {
val expectedType = context[BindingContext.EXPECTED_EXPRESSION_TYPE, it]
expectedType != null && !expectedType.isNullable()
it.parent is KtCallExpression || expectedType != null && !expectedType.isNullable()
}
is KtBinaryExpressionWithTypeRHS -> {
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 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()