diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.fir.kt new file mode 100644 index 00000000000..debe29d832a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.fir.kt @@ -0,0 +1,42 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +package my + +// Accepts block, can't be distinguished from kotlin.contract without resolve +fun contract(block: () -> Unit) {} + +// Accepts int, potentially can be distinguished from kotlin.contract by PSI, +// but as of Kotlin 1.3.0, we don't do that +fun contract(i: Int) {} + +fun doStuff() {} + +class SomeClass { + + fun contract() {} + + fun callMemberContractWithThis() { + this.contract() + } + + fun callMemberContractWithoutThis() { + contract() + } + + fun callTopLevelSamePsiInMember() { + contract { } + } +} + +fun callTopLevelSamePsi() { + contract { } +} + +fun callTopLevelDifferentPsi() { + contract(42) +} + +fun callTopLevelSamePsiNotFirstStatement() { + doStuff() + contract { } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.kt index 6dc12919cc4..1c03aa81914 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/callUsualContractFunction.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER package my diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.3.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.3.fir.kt index 5599da3b303..479961a85b4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.3.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.3.fir.kt @@ -58,11 +58,11 @@ val topLevelAnonymousFunction = fun (x: Boolean) { var topLevelPropertyAccessors: Int? = 42 get() { - contract { returns() implies (field != null) } + contract { returns() implies (field != null) } return 42 } set(value) { - contract { returns() implies (field != null) } + contract { returns() implies (field != null) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.4.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.4.fir.kt index 6b012c9d1a6..375929dbd06 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.4.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.1.4.fir.kt @@ -73,11 +73,11 @@ val topLevelAnonymousFunction = fun (x: Boolean) { var topLevelPropertyAccessors: Int? = 42 get() { - contract { returns() implies (field != null) } + contract { returns() implies (field != null) } return 42 } set(value) { - contract { returns() implies (field != null) } + contract { returns() implies (field != null) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt index e4745964d0a..43ca8bca1ab 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt @@ -25,9 +25,9 @@ fun whenInContract(x: Any?, boolean: Boolean) { fun forInContract(x: Any?) { contract { - for (i in 0..1) { + for (i in 0..1) { returns() implies (x is String) - } + } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.fir.kt new file mode 100644 index 00000000000..fc4bce32a68 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.fir.kt @@ -0,0 +1,39 @@ +// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts +// !LANGUAGE: +UseReturnsEffect +// Issue: KT-26386 + +fun myRun(block: () -> Unit) { + block() +} + +fun contract(block: () -> Unit) { + block() +} + +fun case_1(): Boolean? { + contract { case_1() } + return null +} + +fun case_2(): Boolean? { + contract { case_3() } + return null +} + +fun case_3(): Boolean? { + contract { case_2() } + return null +} + +fun case4() { + contract { + myRun { + val s: String + run { + s = "hello" + } + s.length + } + } +} + diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.kt index a7dc2dd7ebd..1b57f6a6d0f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContractCustomContractFunction.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts // !LANGUAGE: +UseReturnsEffect // Issue: KT-26386 diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt index d5d09e9f68a..19f33a80b18 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* class Foo(val x: Int?) { fun isXNull(): Boolean { contract { - returns(false) implies (x != null) + returns(false) implies (x != null) } return x != null } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt index a555c1111e7..50094ad12d5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* class Foo(val x: Int?) { fun isXNull(): Boolean { contract { - returns(false) implies (x != null) + returns(false) implies (x != null) } return x != null } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.fir.kt index 55a1532bced..590400d94a6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/useBeforeDeclaration.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun test(x: Any?) { if (isString(x)) { - x.length + x.length } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt index 52a26b6c3e6..576f9274b5d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt @@ -13,5 +13,5 @@ fun myAssert(condition: Boolean, message: String = "") { fun test(x: Any?) { myAssert(x is String) - x.length + x.length } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt index 27f981a82c9..950164c591d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt @@ -14,8 +14,8 @@ fun myAssert(condition: Boolean) { fun testWithCatch(x: Any?) { try { myAssert(x is String) - x.length + x.length } catch (e: java.lang.IllegalArgumentException) { } - x.length + x.length } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/compositions.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/compositions.fir.kt index 63f22fe0615..041dd2ac34e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/compositions.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/compositions.fir.kt @@ -13,7 +13,7 @@ fun isString(x: Any?): Boolean { fun testEqualsWithConstant(x: Any?) { if (isString(x) == true) { - x.length + x.length } else { x.length @@ -25,7 +25,7 @@ fun testNotEqualsWithConstant(x: Any?) { x.length } else { - x.length + x.length } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt index 98c235dc144..e002daa345f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt @@ -19,7 +19,7 @@ class Foo { fun test_1(foo: Foo, x: Any) { foo.require(x is String) - x.length + x.length } fun test_2(foo: Foo): Int { diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt index 29421c67cd6..c12cbec1cca 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt @@ -54,7 +54,7 @@ fun nullWhenNotString(x: Any?): String? { fun nested1(x: Any?) { if (equalsTrue(isString(x))) { - x.length + x.length } else { x.length @@ -63,7 +63,7 @@ fun nested1(x: Any?) { fun nested2(x: Any?) { myAssert(equalsTrue(isString(x))) - x.length + x.length } fun nested3(x: Any?) { @@ -74,14 +74,14 @@ fun nested3(x: Any?) { fun branchedAndNested(x: Any?, y: Any?) { myAssert(equalsTrue(notEqualsNull(nullWhenNotString(x))) && equalsTrue(isString(y))) x.length - y.length + y.length } fun br(y: Any?) { if (myAssert(y is Int) == Unit && myAssert(y is String) == Unit) { - y.length - y.inc() + y.length + y.inc() } } @@ -98,7 +98,7 @@ fun branchedAndNestedWithNativeOperators(x: Any?, y: Any?) { (1 == 2 || y is Int || isString(y)) ) x.length - y.length - y.inc() + y.length + y.inc() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.fir.kt index 36be683de7a..189609f3467 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.fir.kt @@ -29,7 +29,7 @@ fun notIsInt(x: Any?): Boolean { fun intersectingInfo(x: Any?, y: Any?) { if ((isString(x) && y is String) || (!notIsString(x) && !notIsInt(y))) { - x.length + x.length y.length y.inc() } @@ -48,7 +48,7 @@ fun intersectingInfo2(x: Any?, y: Any?) { if ((isString(x) && !notIsInt(x) && y is String) || (!notIsString(x) && isString(y) && y is Int) || (x is String && !notIsInt(y) && x is Int)) { - x.length + x.length x.inc() y.length y.inc() diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.fir.kt index 145c2eae9bd..4eb2c5dc30a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.fir.kt @@ -23,8 +23,8 @@ fun testDeMorgan(x: Any?) { // !(x !is String || x !is Int) // x is String && x is Int if (!(notIsString(x) || notIsInt(x))) { - x.length - x.inc() + x.length + x.inc() } else { x.length @@ -39,7 +39,7 @@ fun testDeMorgan2(x: Any?) { x.inc() } else { - x.length - x.inc() + x.length + x.inc() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/implicitIff.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/implicitIff.fir.kt index e9d58ce0f67..e2d4afea643 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/implicitIff.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/implicitIff.fir.kt @@ -32,7 +32,7 @@ fun trueAndFalse(b: Boolean): Boolean { fun useOnlyTrueInTrueBranch(x: Any?) { if (onlyTrue(x is String)) { - x.length + x.length } else { x.length @@ -64,13 +64,13 @@ fun useOnlyFalseInFalseBranch(x: Any?) { x.length } else { - x.length + x.length } } fun useTrueAndFalseInTrueBranch(x: Any?) { if (trueAndFalse(x is String)) { - x.length + x.length } else { x.length @@ -82,6 +82,6 @@ fun useTrueAndFalseInFalseBranch(x: Any?) { x.length } else { - x.length + x.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt index 9dc44536e09..3491f299fc4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt @@ -22,7 +22,7 @@ fun smartcastAndInitialization(x: Any?) { if (callsAndInverts(x !is String) { y = 42 }) { println(y) - x.length + x.length } else { println(y) x.length @@ -35,7 +35,7 @@ fun inPresenceOfLazy(x: Any?, unknownBoolean: Boolean) { if (unknownBoolean && callsAndInverts(x !is String) { y = 42 }) { println(y) - x.length + x.length } else { println(y) @@ -47,7 +47,7 @@ fun inPresenceOfLazy(x: Any?, unknownBoolean: Boolean) { fun isPresenceOfLazy2(x: Any?, unknownBoolean: Boolean) { val y: Int if (unknownBoolean && callsAndInverts(x !is String) { y = 42 }) { - x.length + x.length } else { println(y) @@ -59,7 +59,7 @@ fun isPresenceOfLazy2(x: Any?, unknownBoolean: Boolean) { fun isPresenceOfLazy3(x: Any?, unknownBoolean: Boolean) { val y: Int if (unknownBoolean && callsAndInverts(x !is String) { y = 42 }) { - x.length + x.length } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/nullabilitySmartcastWhenNullability.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/nullabilitySmartcastWhenNullability.fir.kt index f91f8ddd50a..dd68690573f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/nullabilitySmartcastWhenNullability.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/nullabilitySmartcastWhenNullability.fir.kt @@ -14,7 +14,7 @@ fun nullWhenNull(x: Int?): Int? { fun testNullWhenNull(x: Int?) { if (nullWhenNull(x) == null) { - x.dec() + x.dec() } else { x.dec() @@ -24,7 +24,7 @@ fun testNullWhenNull(x: Int?) { x.dec() } else { - x.dec() + x.dec() } x.dec() diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.fir.kt index c71e14966dd..0de0dbe72a4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.fir.kt @@ -38,8 +38,8 @@ fun falseWhenInt(x: Any?): Boolean { fun truetrue(x: Any?) { if (trueWhenString(x) && trueWhenInt(x)) { - x.length - x.inc() + x.length + x.inc() } x.length x.inc() @@ -47,7 +47,7 @@ fun truetrue(x: Any?) { fun truefalse(x: Any?) { if (trueWhenString(x) && falseWhenInt(x)) { - x.length + x.length x.inc() } else { @@ -59,7 +59,7 @@ fun truefalse(x: Any?) { fun falsetrue(x: Any?) { if (falseWhenString(x) && trueWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithConstant.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithConstant.fir.kt index 6ef3ca6f18c..aa7e89d6f6b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithConstant.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithConstant.fir.kt @@ -23,7 +23,7 @@ fun falseWhenString(x: Any?): Boolean { fun annotatedTrueAndTrue(x: Any?) { if (trueWhenString(x) && true) { - x.length + x.length } else { x.length @@ -33,7 +33,7 @@ fun annotatedTrueAndTrue(x: Any?) { fun annotatedTrueAndFalse(x: Any?) { if (trueWhenString(x) && false) { // Unreachable - x.length + x.length } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithUnknown.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithUnknown.fir.kt index 79bd086d88b..127da358de7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithUnknown.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperatorWithUnknown.fir.kt @@ -25,7 +25,7 @@ fun unknownFunction(x: Any?) = x == 42 fun annotatedTrue(x: Any?) { if (trueWhenString(x) && unknownFunction(x)) { - x.length + x.length } else { x.length @@ -43,7 +43,7 @@ fun annotatedFalse(x: Any?) { fun annotatedTrueWithVariable(x: Any?, b: Boolean) { if (trueWhenString(x) && b) { - x.length + x.length } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsOperator.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsOperator.fir.kt index db2ed812e47..b9b869596c4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsOperator.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsOperator.fir.kt @@ -26,7 +26,7 @@ fun testBasicEquals(x: Int?) { x.inc() } else { - x.inc() + x.inc() } x.inc() @@ -36,7 +36,7 @@ fun testBasicNotEquals(x: Int?) { x.inc() if (myEqualsNotNull(x)) { - x.inc() + x.inc() } else { x.inc() diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsWithNullableBoolean.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsWithNullableBoolean.fir.kt index 74db3f0de4e..bec71fc96ca 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsWithNullableBoolean.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/equalsWithNullableBoolean.fir.kt @@ -16,7 +16,7 @@ fun safeIsString(x: Any?): Boolean? { fun equalsTrue(x: Any?) { if (safeIsString(x) == true) { - x.length + x.length } else { x.length @@ -28,7 +28,7 @@ fun equalsFalse(x: Any?) { x.length } else { - x.length + x.length } } @@ -46,13 +46,13 @@ fun notEqualsTrue(x: Any?) { x.length } else { - x.length + x.length } } fun notEqualsFalse(x: Any?) { if (safeIsString(x) != false) { - x.length + x.length } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/isInstanceOperator.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/isInstanceOperator.fir.kt index 87ca4fe3448..514407cc298 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/isInstanceOperator.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/isInstanceOperator.fir.kt @@ -26,7 +26,7 @@ fun testSimple(x: Any?) { x.length if (isString(x)) { - x.length + x.length } else { x.length @@ -36,7 +36,7 @@ fun testSimple(x: Any?) { fun testSpilling(x: Any?) { x.length - if (isString(x)) x.length + if (isString(x)) x.length x.length } @@ -46,14 +46,14 @@ fun testInversion(x: Any?) { x.length } else { - x.length + x.length } } fun testInversionSpilling(x: Any?) { x.length - if (notIsString(x)) else x.length + if (notIsString(x)) else x.length x.length } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.fir.kt index 2d34f9ab762..c95b39eebdd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.fir.kt @@ -51,7 +51,7 @@ fun truefalse(x: Any?) { } else { x.length - x.inc() + x.inc() } } @@ -61,7 +61,7 @@ fun falsetrue(x: Any?) { x.inc() } else { - x.length + x.length x.inc() } } @@ -72,7 +72,7 @@ fun falsefalse(x: Any?) { x.inc() } else { - x.length - x.inc() + x.length + x.inc() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithConstant.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithConstant.fir.kt index d23f3ec6f34..816c747dd99 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithConstant.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithConstant.fir.kt @@ -43,7 +43,7 @@ fun annotatedFalseOrTrue(x: Any?) { } else { // Unreachable - x.length + x.length } } @@ -52,6 +52,6 @@ fun annotatedFalseOrFalse(x: Any?) { x.length } else { - x.length + x.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithUnknown.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithUnknown.fir.kt index c923d79e88e..70faf07d3bf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithUnknown.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperatorWithUnknown.fir.kt @@ -37,7 +37,7 @@ fun annotatedFalse(x: Any?) { x.length } else { - x.length + x.length } } @@ -55,6 +55,6 @@ fun annotatedFalseWithVariable(x: Any?, b: Boolean) { x.length } else { - x.length + x.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt index 5b0a30c506d..b1706dd9f02 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/partiallyIncorrect.fir.kt @@ -13,7 +13,7 @@ fun isString(x: Any?): Boolean { fun incorrectPartDoesntMatter(x: Any?) { if (isString(x) && 1) { - x.length + x.length } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/receiver.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/receiver.fir.kt index 9d993cd451f..474ba3a6482 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/receiver.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/receiver.fir.kt @@ -17,7 +17,7 @@ fun smartcastOnReceiver(x: Int?) { x.inc() } else { - x.dec() + x.dec() } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt index c54df88cf4c..1253490875b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt @@ -13,7 +13,7 @@ fun myAssert(condition: Boolean) { fun testAssertSmartcast(x: Any?) { myAssert(x is String) - x.length + x.length } fun testInvertedAssert(x: Any?) { @@ -24,34 +24,34 @@ fun testInvertedAssert(x: Any?) { fun testSpilling(x: Any?) { if (x != null) { myAssert(x is String) - x.length + x.length } x.length } fun testAssertInIf(x: Any?) { if (myAssert(x is String) == Unit) { - x.length + x.length } else { - x.length + x.length } } fun testTryCatch(x: Any?) { try { myAssert(x is String) - x.length + x.length } catch (e: kotlin.IllegalArgumentException) { } - x.length + x.length } fun testUncertainFlow(x: Any?) { repeat(x.toString().length) { myAssert(x is String) - x.length + x.length } x.length } @@ -59,8 +59,8 @@ fun testUncertainFlow(x: Any?) { fun testAtLeastOnceFlow(x: Any?) { do { myAssert(x is String) - x.length + x.length } while (x != null) - x.length + x.length } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/typeSmartcastWhenNullability.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/typeSmartcastWhenNullability.fir.kt index 5c032d8b228..dd9904f1dd1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/typeSmartcastWhenNullability.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/typeSmartcastWhenNullability.fir.kt @@ -29,7 +29,7 @@ fun nullWhenNotString(x: Any?): Int? { fun test1(x: Any?) { // condition == true <=> function returned null <=> 'x' is String if (nullWhenString(x) == null) { - x.length + x.length } else { x.length @@ -43,7 +43,7 @@ fun test2(x: Any?) { x.length } else { - x.length + x.length } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.fir.kt index 12cf3f1112b..6dec79f5f3a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/unreachableBranches.fir.kt @@ -17,7 +17,7 @@ fun isString(x: Any?): Boolean { fun implicitAlwaysFalse(x: Any?) { if (isString(x) && !isString(x)) { - x.length + x.length } else { x.length @@ -26,7 +26,7 @@ fun implicitAlwaysFalse(x: Any?) { fun implicitAlwaysFalseSpilling(x: Any?) { if (isString(x) && !isString(x)) { - x.length + x.length } x.length } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubject.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubject.fir.kt index 0315f2c2357..1e5423b7c0e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubject.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubject.fir.kt @@ -13,24 +13,24 @@ fun isString(x: Any?): Boolean { fun exhaustive(x: Any?) { when (isString(x)) { - true -> x.length + true -> x.length false -> x.length } when(!isString(x)) { true -> x.length - false -> x.length + false -> x.length } } fun smartcastInElse(x: Any?) { when (isString(x)) { false -> x.length - else -> x.length + else -> x.length } when (!isString(x)) { true -> x.length - else -> x.length + else -> x.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubjectNullableBoolean.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubjectNullableBoolean.fir.kt index c0e3058acae..a6d2b6e1db2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubjectNullableBoolean.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withSubjectNullableBoolean.fir.kt @@ -14,22 +14,22 @@ fun safeIsString(x: Any?): Boolean? { fun elseWithNullableResult(x: Any?) { when (safeIsString(x)) { false -> x.length + else -> x.length + } + + when (safeIsString(x)) { + true -> x.length else -> x.length } when (safeIsString(x)) { - true -> x.length - else -> x.length - } - - when (safeIsString(x)) { - true -> x.length + true -> x.length false -> x.length else -> x.length } when (safeIsString(x)) { - true -> x.length + true -> x.length null -> x.length else -> x.length } @@ -37,20 +37,20 @@ fun elseWithNullableResult(x: Any?) { fun exhaustiveWithNullableResult(x: Any?) { when (safeIsString(x)) { - true -> x.length + true -> x.length false -> x.length null -> x.length } when (safeIsString(x)) { false -> x.length - true -> x.length - null -> x.length + true -> x.length + null -> x.length } when (safeIsString(x)) { false -> x.length - null -> x.length - true -> x.length + null -> x.length + true -> x.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withoutSubject.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withoutSubject.fir.kt index aea3e2db6da..a49baaecc76 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withoutSubject.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/when/withoutSubject.fir.kt @@ -13,19 +13,19 @@ fun isString(x: Any?): Boolean { fun exhaustive(x: Any?) { when { - isString(x) -> x.length + isString(x) -> x.length !isString(x) -> x.length } when { !isString(x) -> x.length - isString(x) -> x.length + isString(x) -> x.length } } fun smartcastInElse(x: Any?) { when { !isString(x) -> x.length - else -> x.length + else -> x.length } } \ No newline at end of file