Load compiler language version settings for foreign annotations tests

To set specific features for compiler tests
This commit is contained in:
Mikhail Zarechenskiy
2017-11-08 11:06:18 +03:00
parent 63b13027df
commit 85d442133d
2 changed files with 15 additions and 5 deletions
@@ -28,7 +28,8 @@ data class CompilerTestLanguageVersionSettings(
private val languageFeatures: Map<LanguageFeature, LanguageFeature.State>,
override val apiVersion: ApiVersion,
override val languageVersion: LanguageVersion,
private val specificFeatures: Map<LanguageFeature, LanguageFeature.State> = specificFeaturesForTests()
private val specificFeatures: Map<LanguageFeature, LanguageFeature.State> = specificFeaturesForTests(),
private val analysisFlags: Map<AnalysisFlag<*>, Any?> = emptyMap()
) : LanguageVersionSettings {
private val delegate = LanguageVersionSettingsImpl(languageVersion, apiVersion)
@@ -37,7 +38,8 @@ data class CompilerTestLanguageVersionSettings(
languageFeatures[feature] ?:
delegate.getFeatureSupport(feature)
override fun <T> getFlag(flag: AnalysisFlag<T>): T = flag.defaultValue
@Suppress("UNCHECKED_CAST")
override fun <T> getFlag(flag: AnalysisFlag<T>): T = analysisFlags[flag] as T? ?: flag.defaultValue
}
private fun specificFeaturesForTests(): Map<LanguageFeature, LanguageFeature.State> {
@@ -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.
@@ -17,7 +17,10 @@
package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.AnalysisFlag
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import org.jetbrains.kotlin.test.MockLibraryUtil
@@ -61,7 +64,12 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
override fun loadLanguageVersionSettings(module: List<TestFile>): LanguageVersionSettings {
val analysisFlags = loadAnalysisFlags(module)
return LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, analysisFlags)
return CompilerTestLanguageVersionSettings(
DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
ApiVersion.LATEST_STABLE,
LanguageVersion.LATEST_STABLE,
analysisFlags = analysisFlags
)
}
private fun loadAnalysisFlags(module: List<TestFile>): Map<AnalysisFlag<*>, Any?> {