From 7d8363d6aafded74c43d5e30155bd6d16fac5a55 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 24 Jan 2020 11:35:37 +0300 Subject: [PATCH] [FIR] Use `Function` as super type for all `FunctionN`types --- .../jetbrains/kotlin/fir/symbols/StandardClassIds.kt | 2 ++ .../fir/resolve/impl/FirBuiltinSymbolProvider.kt | 12 ++++++++++-- .../stdlib/{problems => }/functionAndFunctionN.kt | 2 +- .../stdlib/{problems => }/functionAndFunctionN.txt | 2 +- .../fir/FirDiagnosticsWithStdlibTestGenerated.java | 10 +++++----- .../diagnostics/tests/smartCasts/kt32358_2.fir.kt | 2 +- .../breakContinuesInInlinedLambda.fir.kt | 2 +- .../controlflow/flowInlining/expressionBody.fir.kt | 2 +- .../implicitCastToAnyInReturnType.fir.kt | 2 +- .../flowInlining/inlinedLambdaAlwaysThrows.fir.kt | 2 +- .../flowInlining/irrelevantUnknownClosure.fir.kt | 2 +- .../controlflow/flowInlining/labeledReturns.fir.kt | 4 ++-- .../flowInlining/nestedTryCatchFinally.fir.kt | 2 +- .../controlflow/flowInlining/nestedTryCatchs.fir.kt | 2 +- .../controlflow/flowInlining/nonLocalReturn.fir.kt | 2 +- .../flowInlining/nonReturningInlinedLambda.fir.kt | 2 +- .../flowInlining/safeCallAndInPlaceReturn.fir.kt | 2 +- .../severalJumpOutsFromInlinedLambda.fir.kt | 2 +- .../controlflow/flowInlining/throwIfNotCalled.fir.kt | 2 +- .../controlflow/flowInlining/tryCatch.fir.kt | 2 +- .../controlflow/flowInlining/tryCatchFinally.fir.kt | 2 +- .../controlflow/flowInlining/typeMismatch.fir.kt | 2 +- .../controlflow/flowInlining/unreachableCode.fir.kt | 2 +- .../atLeastOnce/valDefiniteReassignment.fir.kt | 4 ++-- .../atLeastOnce/varDefiniteInitialization.fir.kt | 2 +- .../atLeastOnce/varIndefiniteIntialization.fir.kt | 2 +- .../exactlyOnce/valDefiniteInitialization.fir.kt | 2 +- .../exactlyOnce/valDefiniteReassignment.fir.kt | 2 +- .../exactlyOnce/valIndefiniteInitialization.fir.kt | 4 ++-- .../exactlyOnce/varDefiniteInitalization.fir.kt | 2 +- .../exactlyOnce/varIndefiniteInitialization.fir.kt | 2 +- .../initialization/exactlyOnce/withReceiver.fir.kt | 2 +- .../initialization/unknown/unknownInvocations.fir.kt | 2 +- .../contracts/dsl/errors/notFirstStatement.fir.kt | 8 ++++---- .../contracts/dsl/fqnContractFunction.fir.kt | 2 +- .../contracts/smartcasts/contractsOnMembers.fir.kt | 2 +- .../smartcasts/multieffect/returnsAndCalls.fir.kt | 2 +- 37 files changed, 57 insertions(+), 47 deletions(-) rename compiler/fir/resolve/testData/resolve/stdlib/{problems => }/functionAndFunctionN.kt (59%) rename compiler/fir/resolve/testData/resolve/stdlib/{problems => }/functionAndFunctionN.txt (73%) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index 62bd6bfffe1..4b756f73df6 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -40,6 +40,8 @@ object StandardClassIds { val Comparable = "Comparable".baseId() val Number = "Number".baseId() + val Function = "Function".baseId() + fun byName(name: String) = name.baseId() fun reflectByName(name: String) = name.reflectId() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt index 250c29f92a0..6262cc41b3a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/impl/FirBuiltinSymbolProvider.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -250,18 +251,25 @@ class FirBuiltinSymbolProvider(val session: FirSession, val kotlinScopeProvider: } val superTypes = when (kind) { + FunctionClassDescriptor.Kind.Function -> + listOf( + FirResolvedTypeRefImpl( + source = null, + ConeClassLikeLookupTagImpl(StandardClassIds.Function) + .constructClassType(arrayOf(typeArguments.last().type), isNullable = false) + ) + ) - FunctionClassDescriptor.Kind.Function, FunctionClassDescriptor.Kind.SuspendFunction -> listOf(session.builtinTypes.anyType) FunctionClassDescriptor.Kind.KFunction -> listOf(createSuperType(FunctionClassDescriptor.Kind.Function)) + FunctionClassDescriptor.Kind.KSuspendFunction -> listOf(createSuperType(FunctionClassDescriptor.Kind.SuspendFunction)) } replaceSuperTypeRefs(superTypes) - } } } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.kt b/compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.kt similarity index 59% rename from compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.kt rename to compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.kt index eb6c0a86ad6..cfcf7dd84ae 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.kt @@ -1,5 +1,5 @@ fun takeAnyFun(function: Function<*>) {} fun test(block: () -> Unit) { - takeAnyFun(block) + takeAnyFun(block) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.txt b/compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.txt similarity index 73% rename from compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.txt rename to compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.txt index 1fe3fc5d985..1049b115175 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.txt @@ -2,5 +2,5 @@ FILE: functionAndFunctionN.kt public final fun takeAnyFun(function: R|kotlin/Function<*>|): R|kotlin/Unit| { } public final fun test(block: R|() -> kotlin/Unit|): R|kotlin/Unit| { - #(R|/block|) + R|/takeAnyFun|(R|/block|) } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index bd907d281db..ac575580072 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -83,6 +83,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/factoryFunctionOverloads.kt"); } + @TestMetadata("functionAndFunctionN.kt") + public void testFunctionAndFunctionN() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/functionAndFunctionN.kt"); + } + @TestMetadata("functionX.kt") public void testFunctionX() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/functionX.kt"); @@ -607,11 +612,6 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/delegateTypeMismatch.kt"); } - @TestMetadata("functionAndFunctionN.kt") - public void testFunctionAndFunctionN() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/functionAndFunctionN.kt"); - } - @TestMetadata("inapplicableRemoveAll.kt") public void testInapplicableRemoveAll() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/inapplicableRemoveAll.kt"); diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt32358_2.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/kt32358_2.fir.kt index 84e4116f5b9..b40f1f40089 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt32358_2.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt32358_2.fir.kt @@ -7,7 +7,7 @@ inline fun callIt(fn: () -> R): R = TODO() inline fun callItContracted(fn: () -> R): R { contract { - callsInPlace(fn, InvocationKind.EXACTLY_ONCE) + callsInPlace(fn, InvocationKind.EXACTLY_ONCE) } TODO() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/breakContinuesInInlinedLambda.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/breakContinuesInInlinedLambda.fir.kt index 4451a6280ab..7cd95e81dfe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/breakContinuesInInlinedLambda.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/breakContinuesInInlinedLambda.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/expressionBody.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/expressionBody.fir.kt index 58dd06fbec4..157c016709d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/expressionBody.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/expressionBody.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/implicitCastToAnyInReturnType.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/implicitCastToAnyInReturnType.fir.kt index 5b0f4b45bb1..4e0a246c9c3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/implicitCastToAnyInReturnType.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/implicitCastToAnyInReturnType.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt index fc8123558a6..df14fafcbd9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> Unit): Unit { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/irrelevantUnknownClosure.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/irrelevantUnknownClosure.fir.kt index 7f121224199..9c26e6a7f3b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/irrelevantUnknownClosure.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/irrelevantUnknownClosure.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> Unit): Unit { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt index 93b55158aba..16a2a4916d9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/labeledReturns.fir.kt @@ -6,14 +6,14 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } inline fun T.myLet(block: (T) -> R): R { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block(this) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchFinally.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchFinally.fir.kt index db6eeffc9b5..1c0335c28c2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchFinally.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchFinally.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchs.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchs.fir.kt index af0e303142f..7034751ecd1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchs.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nestedTryCatchs.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonLocalReturn.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonLocalReturn.fir.kt index 6b5347c24ce..a33f7f59b4d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonLocalReturn.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonLocalReturn.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun T.myLet(block: (T) -> R): R { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block(this) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonReturningInlinedLambda.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonReturningInlinedLambda.fir.kt index c1a05e5289b..bc6f7baa181 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonReturningInlinedLambda.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/nonReturningInlinedLambda.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> Unit): Unit { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt index c154232b52f..4d895ffeb05 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/safeCallAndInPlaceReturn.fir.kt @@ -5,7 +5,7 @@ import kotlin.contracts.* inline fun Any?.myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/severalJumpOutsFromInlinedLambda.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/severalJumpOutsFromInlinedLambda.fir.kt index 75a48f21ad1..24c484e8e91 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/severalJumpOutsFromInlinedLambda.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/severalJumpOutsFromInlinedLambda.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt index 979b54e2721..e8deda72a6c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> Unit) { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatch.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatch.fir.kt index f616a5fec21..549325b6b8b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatch.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatch.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatchFinally.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatchFinally.fir.kt index f4f20190699..c62c45b5a24 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatchFinally.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/tryCatchFinally.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/typeMismatch.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/typeMismatch.fir.kt index e0015888b81..18ffdb6b2f3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/typeMismatch.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/typeMismatch.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt index d19c6127d7b..9dcfe5a6b28 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* inline fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/valDefiniteReassignment.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/valDefiniteReassignment.fir.kt index 0618ddbddf3..2dc03211a3d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/valDefiniteReassignment.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/valDefiniteReassignment.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun runTwice(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.AT_LEAST_ONCE) + callsInPlace(block, InvocationKind.AT_LEAST_ONCE) } block() return block(); @@ -14,7 +14,7 @@ fun runTwice(block: () -> T): T { fun runOnce(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block(); }; diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varDefiniteInitialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varDefiniteInitialization.fir.kt index 52614a207e6..dae551d2c74 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varDefiniteInitialization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varDefiniteInitialization.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun runTwice(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.AT_LEAST_ONCE) + callsInPlace(block, InvocationKind.AT_LEAST_ONCE) } block() return block(); diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt index 5495be36dbf..09ca700a4e2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun runTwice(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.AT_LEAST_ONCE) + callsInPlace(block, InvocationKind.AT_LEAST_ONCE) } block() return block(); diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteInitialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteInitialization.fir.kt index 51af3aa7e9d..e63f28fb23c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteInitialization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteInitialization.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteReassignment.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteReassignment.fir.kt index facb05750e3..0a493dfc1e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteReassignment.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valDefiniteReassignment.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valIndefiniteInitialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valIndefiniteInitialization.fir.kt index f8189380d92..58c2c58fef9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valIndefiniteInitialization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/valIndefiniteInitialization.fir.kt @@ -6,14 +6,14 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } fun myRepeat(n: Int, action: () -> Unit) { contract { - callsInPlace(action) + callsInPlace(action) } for (i in 1..n) action() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varDefiniteInitalization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varDefiniteInitalization.fir.kt index a8f603bad54..d7ec16a537e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varDefiniteInitalization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varDefiniteInitalization.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varIndefiniteInitialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varIndefiniteInitialization.fir.kt index 0c426acd468..54fe4eac746 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varIndefiniteInitialization.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/varIndefiniteInitialization.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun myRun(block: () -> T): T { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/withReceiver.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/withReceiver.fir.kt index d6874031a9b..4df46d06195 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/withReceiver.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/exactlyOnce/withReceiver.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun T.myLet(block: (T) -> R): R { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block(this) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/unknown/unknownInvocations.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/unknown/unknownInvocations.fir.kt index 31a9ce473a5..b3affbf0f8a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/unknown/unknownInvocations.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/unknown/unknownInvocations.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun inPlace(block: () -> T): T { contract { - callsInPlace(block) + callsInPlace(block) } return block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/notFirstStatement.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/notFirstStatement.fir.kt index 9ac8ce1004c..97f26b0b553 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/notFirstStatement.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/notFirstStatement.fir.kt @@ -15,23 +15,23 @@ fun foo(y: Boolean) { inline fun case1(block: () -> Unit) { val contracts = listOf( contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) }, contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } ) block() } inline fun case_2(block: () -> Unit) = contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } fun case_3(block: () -> Unit) { class Class { fun innerFun(block2: () -> Unit) { contract { - callsInPlace(block2, InvocationKind.EXACTLY_ONCE) + callsInPlace(block2, InvocationKind.EXACTLY_ONCE) } block2() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/fqnContractFunction.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/fqnContractFunction.fir.kt index 12a37c7caf5..d47cf86de0f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/fqnContractFunction.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/fqnContractFunction.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.InvocationKind inline fun foo(block: () -> Unit) { kotlin.contracts.contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt index 850b45ba059..98c235dc144 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/contractsOnMembers.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* class Foo { fun myRun(block: () -> Unit) { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) } block() } 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 003741e33ad..9dc44536e09 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/multieffect/returnsAndCalls.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun callsAndInverts(b: Boolean, block: () -> Unit): Boolean { contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) + callsInPlace(block, InvocationKind.EXACTLY_ONCE) returns(true) implies (!b) returns(false) implies b }