From 81406a2bac23a8a56d3e88b34855f49f912a0798 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 12 Sep 2018 17:31:05 +0300 Subject: [PATCH] Change .hashCode() to .bar() for some nullability fixes tests Hash code can be no more used because in 1.3 we have nullable extension. This fixes two wrap with safe let call tests and one surround with null check test. --- .../surroundWithNullCheck/unsafeCallInsideAnonymous.kt | 4 +++- .../surroundWithNullCheck/unsafeCallInsideAnonymous.kt.after | 4 +++- .../quickfix/wrapWithSafeLetCall/expressionUnsafeCall.kt | 4 +++- idea/testData/quickfix/wrapWithSafeLetCall/unstableValue.kt | 5 +++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt b/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt index e18c3a30c29..e43823fea58 100644 --- a/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt +++ b/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt @@ -1,6 +1,8 @@ // "Surround with null check" "true" // WITH_RUNTIME +fun Int.bar() = this + fun foo(arg: Int?) { - run(fun() = arg.hashCode()) + run(fun() = arg.bar()) } \ No newline at end of file diff --git a/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt.after b/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt.after index a8aca7d1c82..add8b50a3de 100644 --- a/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt.after +++ b/idea/testData/quickfix/surroundWithNullCheck/unsafeCallInsideAnonymous.kt.after @@ -1,8 +1,10 @@ // "Surround with null check" "true" // WITH_RUNTIME +fun Int.bar() = this + fun foo(arg: Int?) { if (arg != null) { - run(fun() = arg.hashCode()) + run(fun() = arg.bar()) } } \ No newline at end of file diff --git a/idea/testData/quickfix/wrapWithSafeLetCall/expressionUnsafeCall.kt b/idea/testData/quickfix/wrapWithSafeLetCall/expressionUnsafeCall.kt index f7266b0f6f8..dc6bcb44f99 100644 --- a/idea/testData/quickfix/wrapWithSafeLetCall/expressionUnsafeCall.kt +++ b/idea/testData/quickfix/wrapWithSafeLetCall/expressionUnsafeCall.kt @@ -6,4 +6,6 @@ // ACTION: Replace with safe (?.) call // ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Int? -fun foo(arg: Int?) = arg.hashCode() \ No newline at end of file +fun Int.bar() = this + +fun foo(arg: Int?) = arg.bar() \ No newline at end of file diff --git a/idea/testData/quickfix/wrapWithSafeLetCall/unstableValue.kt b/idea/testData/quickfix/wrapWithSafeLetCall/unstableValue.kt index 370b14fa998..6ae07ce98d1 100644 --- a/idea/testData/quickfix/wrapWithSafeLetCall/unstableValue.kt +++ b/idea/testData/quickfix/wrapWithSafeLetCall/unstableValue.kt @@ -1,13 +1,14 @@ // "Wrap with '?.let { ... }' call" "false" // WITH_RUNTIME // ACTION: Add non-null asserted (!!) call -// ACTION: Introduce local variable // ACTION: Replace with safe (?.) call // ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Int? +fun Int.bar() {} + class My(var x: Int?) { fun foo() { - x.hashCode() + x.bar() } } \ No newline at end of file