diff --git a/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt b/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt index 77c2f564f44..edfb0590157 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt @@ -119,8 +119,6 @@ class ContractParsingServices(val languageVersionSettings: LanguageVersionSettin if (functionDescriptor?.isOperator == true) collector.contractNotAllowed("Contracts are not allowed for operator functions") - if (functionDescriptor?.isSuspend == true) collector.contractNotAllowed("Contracts are not allowed for suspend functions") - if (functionDescriptor?.isOverridable == true) collector.contractNotAllowed("Contracts are not allowed for open functions") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.kt similarity index 90% rename from compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.kt rename to compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.kt index 1375083c833..b98c067acef 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.kt @@ -24,7 +24,7 @@ open class Class { } suspend fun suspendMember(x: Boolean) { - contract { returns() implies (x) } + contract { returns() implies (x) } } } @@ -39,7 +39,7 @@ inline fun inlineTopLevel(x: Boolean) { } suspend fun suspendTopLevel(x: Boolean) { - contract { returns() implies (x) } + contract { returns() implies (x) } } // Top-level operator @@ -73,7 +73,7 @@ fun test() { } suspend fun suspendlocalDeclaration(x: Boolean) { - contract { returns() implies (x) } + contract { returns() implies (x) } } val localAnonymousFunction = fun (x: Boolean) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.txt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.txt similarity index 97% rename from compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.txt rename to compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.txt index 52c04eaa580..14901b1fc1b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.txt @@ -7,6 +7,8 @@ public inline fun inlineTopLevel(/*0*/ x: kotlin.Boolean): kotlin.Unit Returns(WILDCARD) -> x public suspend fun suspendTopLevel(/*0*/ x: kotlin.Boolean): kotlin.Unit + Returns(WILDCARD) -> x + public fun test(): kotlin.Unit public fun topLevel(/*0*/ x: kotlin.Boolean): kotlin.Unit Returns(WILDCARD) -> x diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index f9fb66c5462..e331461cdff 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1174,16 +1174,16 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.kt"); } + @TestMetadata("contractCallSites.kt") + public void testContractCallSites() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.kt"); + } + @TestMetadata("emptyContract.kt") public void testEmptyContract() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/emptyContract.kt"); } - @TestMetadata("illegalCallSites.kt") - public void testIllegalCallSites() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.kt"); - } - @TestMetadata("illegalConstructionInContractBlock.kt") public void testIllegalConstructionInContractBlock() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 9d8ea906ae4..363b379e45b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1174,16 +1174,16 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.kt"); } + @TestMetadata("contractCallSites.kt") + public void testContractCallSites() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/contractCallSites.kt"); + } + @TestMetadata("emptyContract.kt") public void testEmptyContract() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/emptyContract.kt"); } - @TestMetadata("illegalCallSites.kt") - public void testIllegalCallSites() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalCallSites.kt"); - } - @TestMetadata("illegalConstructionInContractBlock.kt") public void testIllegalConstructionInContractBlock() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.kt");