From 6d733ff7b99a67f533cd9e17894ff426e103c051 Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 5 Jul 2018 10:42:11 +0300 Subject: [PATCH] Disable ContracsDSL in 1.3 --- .../contracts/parsing/ContractParsingServices.kt | 12 +++++++++++- .../contracts/callsEffect.kt | 2 +- .../contracts/deeplyNestedExpression.kt | 2 +- .../compiledKotlinWithStdlib/contracts/embedding.kt | 2 +- .../contracts/fromStandardKt.kt | 2 +- .../contracts/isInstancePredicate.kt | 2 +- .../contracts/logicOperators.kt | 2 +- .../contracts/multieffectContracts.kt | 2 +- .../contracts/mutualRecursion.kt | 2 +- .../compiledKotlinWithStdlib/contracts/recursion.kt | 2 +- .../contracts/withReceiver.kt | 2 +- .../kotlin/config/LanguageVersionSettings.kt | 3 ++- 12 files changed, 23 insertions(+), 12 deletions(-) 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 4e7ee1884e2..05f625519c9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/contracts/parsing/ContractParsingServices.kt @@ -48,7 +48,17 @@ class ContractParsingServices(val languageVersionSettings: LanguageVersionSettin languageVersionSettings.getFlag(AnalysisFlag.Flags.allowKotlinPackage) val contractDescriptor = when { - !isFeatureTurnedOn || !isContractDescriptionCallPreciseCheck(expression, trace.bindingContext) -> null + !isContractDescriptionCallPreciseCheck(expression, trace.bindingContext) -> null + + !isFeatureTurnedOn -> { + trace.report( + Errors.UNSUPPORTED_FEATURE.on( + expression, + LanguageFeature.AllowContractsForCustomFunctions to languageVersionSettings + ) + ) + null + } !isContractAllowedHere(scope) || !isFirstStatement -> { trace.report(Errors.CONTRACT_NOT_ALLOWED.on(expression)) diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/callsEffect.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/callsEffect.kt index 228d4574fc4..4b1363c42cd 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/callsEffect.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/callsEffect.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/deeplyNestedExpression.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/deeplyNestedExpression.kt index ffe5442dfbf..ae41a1cbd47 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/deeplyNestedExpression.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/deeplyNestedExpression.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/embedding.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/embedding.kt index 3ac48df3889..dcb837e2ff1 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/embedding.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/embedding.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/fromStandardKt.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/fromStandardKt.kt index 64117949f82..62ff34b914c 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/fromStandardKt.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/fromStandardKt.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/isInstancePredicate.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/isInstancePredicate.kt index 7e180ab0833..f23e856e7d9 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/isInstancePredicate.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/isInstancePredicate.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/logicOperators.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/logicOperators.kt index e8abe05a162..571f2fd4451 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/logicOperators.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/logicOperators.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/multieffectContracts.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/multieffectContracts.kt index 53c7d2d1bfc..6202ae7b716 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/multieffectContracts.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/multieffectContracts.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/mutualRecursion.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/mutualRecursion.kt index 6e4da68abc4..342b3b560a2 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/mutualRecursion.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/mutualRecursion.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/recursion.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/recursion.kt index dd069883158..4819c2eff4b 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/recursion.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/recursion.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/withReceiver.kt b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/withReceiver.kt index 16915e146c8..7e5da2eb9f2 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/withReceiver.kt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/contracts/withReceiver.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +AllowContractsForCustomFunctions +ReadDeserializedContracts @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 40f8f93f258..c89445be47c 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -74,7 +74,6 @@ enum class LanguageFeature( UseReturnsEffect(KOTLIN_1_3), UseCallsInPlaceEffect(KOTLIN_1_3), VariableDeclarationInWhenSubject(KOTLIN_1_3), - AllowContractsForCustomFunctions(KOTLIN_1_3, kind = UNSTABLE_FEATURE), ProhibitLocalAnnotations(KOTLIN_1_3, kind = BUG_FIX), ProhibitSmartcastsOnLocalDelegatedProperty(KOTLIN_1_3, kind = BUG_FIX), ProhibitOperatorMod(KOTLIN_1_3, kind = BUG_FIX), @@ -90,6 +89,8 @@ enum class LanguageFeature( State.ENABLED_WITH_WARNING ), + AllowContractsForCustomFunctions(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE), + MultiPlatformProjects(sinceVersion = null, defaultState = State.DISABLED), NewInference(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED),