diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/breakContinuesInInlinedLambda.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/breakContinuesInInlinedLambda.kt index c1362255a2b..8ba1536dcae 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/breakContinuesInInlinedLambda.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/breakContinuesInInlinedLambda.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/inlinedLambdaAlwaysThrows.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/inlinedLambdaAlwaysThrows.kt index d29b2fd8df8..2986c96845d 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/inlinedLambdaAlwaysThrows.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/inlinedLambdaAlwaysThrows.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/irrelevantUnknownClosure.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/irrelevantUnknownClosure.kt index 871b8020b5c..b5a2dacfa90 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/irrelevantUnknownClosure.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/irrelevantUnknownClosure.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchFinally.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchFinally.kt index 2f4ad7f5efa..964add34a06 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchFinally.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchFinally.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchs.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchs.kt index 118e52982f1..f2d98dce0e2 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchs.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/nestedTryCatchs.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/nonReturningInlinedLambda.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/nonReturningInlinedLambda.kt index a75f1ca6fdd..9acb7ccbd4d 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/nonReturningInlinedLambda.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/nonReturningInlinedLambda.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/returnsAndCalls.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/returnsAndCalls.kt index 58be9e1e3d7..d271ee9e9e7 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/returnsAndCalls.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/returnsAndCalls.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/throwIfNotCalled.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/throwIfNotCalled.kt index 8b99500a805..ed87954e459 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/throwIfNotCalled.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/throwIfNotCalled.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatch.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatch.kt index 26981ef7131..ebe340e0d5c 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatch.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatch.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatchFinally.kt b/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatchFinally.kt index 447fbb14629..b8f947e938b 100644 --- a/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatchFinally.kt +++ b/compiler/testData/cfgVariablesWithStdLib/contracts/tryCatchFinally.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgWithStdLib/contracts/labeledReturns.kt b/compiler/testData/cfgWithStdLib/contracts/labeledReturns.kt index a990d6a5ae0..8e3a76f8f15 100644 --- a/compiler/testData/cfgWithStdLib/contracts/labeledReturns.kt +++ b/compiler/testData/cfgWithStdLib/contracts/labeledReturns.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgWithStdLib/contracts/nonReturningInlinedLambda.kt b/compiler/testData/cfgWithStdLib/contracts/nonReturningInlinedLambda.kt index a75f1ca6fdd..9acb7ccbd4d 100644 --- a/compiler/testData/cfgWithStdLib/contracts/nonReturningInlinedLambda.kt +++ b/compiler/testData/cfgWithStdLib/contracts/nonReturningInlinedLambda.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgWithStdLib/contracts/returnsAndCalls.kt b/compiler/testData/cfgWithStdLib/contracts/returnsAndCalls.kt index 58be9e1e3d7..d271ee9e9e7 100644 --- a/compiler/testData/cfgWithStdLib/contracts/returnsAndCalls.kt +++ b/compiler/testData/cfgWithStdLib/contracts/returnsAndCalls.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgWithStdLib/contracts/throwIfNotCalled.kt b/compiler/testData/cfgWithStdLib/contracts/throwIfNotCalled.kt index 8b99500a805..ed87954e459 100644 --- a/compiler/testData/cfgWithStdLib/contracts/throwIfNotCalled.kt +++ b/compiler/testData/cfgWithStdLib/contracts/throwIfNotCalled.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/testData/cfgWithStdLib/contracts/tryCatchFinally.kt b/compiler/testData/cfgWithStdLib/contracts/tryCatchFinally.kt index 447fbb14629..b8f947e938b 100644 --- a/compiler/testData/cfgWithStdLib/contracts/tryCatchFinally.kt +++ b/compiler/testData/cfgWithStdLib/contracts/tryCatchFinally.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +CallsInPlaceEffect import kotlin.internal.contracts.* diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/AbstractPseudocodeTest.java b/compiler/tests/org/jetbrains/kotlin/cfg/AbstractPseudocodeTest.java index 88e280e6098..ce504a549d8 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/AbstractPseudocodeTest.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/AbstractPseudocodeTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,17 +32,12 @@ import org.jetbrains.kotlin.cfg.pseudocode.PseudocodeUtil; import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction; import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl; import org.jetbrains.kotlin.cfg.pseudocode.instructions.special.LocalFunctionDeclarationInstruction; -import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; -import org.jetbrains.kotlin.codegen.CodegenTestCase; -import org.jetbrains.kotlin.config.ApiVersion; import org.jetbrains.kotlin.config.CommonConfigurationKeysKt; -import org.jetbrains.kotlin.config.LanguageVersion; -import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.test.ConfigurationKind; -import org.jetbrains.kotlin.test.InTextDirectivesUtils; import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.KotlinTestWithEnvironmentManagement; @@ -50,8 +45,11 @@ import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Set; +import static org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettingsKt.parseLanguageVersionSettings; + public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironmentManagement { protected void doTestWithStdLib(String fileName) throws Exception { doTestWithEnvironment(fileName, createEnvironmentWithMockJdk(ConfigurationKind.NO_KOTLIN_REFLECT)); @@ -61,20 +59,18 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironmentMa doTestWithEnvironment(fileName, createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY)); } - private void updateEnvironmentWithLanguageVersionDirective(File file, KotlinCoreEnvironment environment) throws IOException { - String version = InTextDirectivesUtils.findStringWithPrefixes(FileUtil.loadFile(file, true), "// LANGUAGE_VERSION:"); - if (version != null) { - LanguageVersion explicitVersion = LanguageVersion.fromVersionString(version); - CommonConfigurationKeysKt.setLanguageVersionSettings( - environment.getConfiguration(), - new LanguageVersionSettingsImpl(explicitVersion, ApiVersion.createByLanguageVersion(explicitVersion)) - ); + private static void setupLanguageVersionSettings(File file, KotlinCoreEnvironment environment) throws IOException { + String fileText = FileUtil.loadFile(file, true); + Map directives = KotlinTestUtils.parseDirectives(fileText); + LanguageVersionSettings languageVersionSettings = parseLanguageVersionSettings(directives); + if (languageVersionSettings != null) { + CommonConfigurationKeysKt.setLanguageVersionSettings(environment.getConfiguration(), languageVersionSettings); } } private void doTestWithEnvironment(String fileName, KotlinCoreEnvironment environment) throws Exception { File file = new File(fileName); - updateEnvironmentWithLanguageVersionDirective(file, environment); + setupLanguageVersionSettings(file, environment); KtFile jetFile = KotlinTestUtils.loadJetFile(environment.getProject(), file); SetMultimap data = LinkedHashMultimap.create();