Load compiler language version settings for foreign annotations tests
To set specific features for compiler tests
This commit is contained in:
+4
-2
@@ -28,7 +28,8 @@ data class CompilerTestLanguageVersionSettings(
|
|||||||
private val languageFeatures: Map<LanguageFeature, LanguageFeature.State>,
|
private val languageFeatures: Map<LanguageFeature, LanguageFeature.State>,
|
||||||
override val apiVersion: ApiVersion,
|
override val apiVersion: ApiVersion,
|
||||||
override val languageVersion: LanguageVersion,
|
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 {
|
) : LanguageVersionSettings {
|
||||||
private val delegate = LanguageVersionSettingsImpl(languageVersion, apiVersion)
|
private val delegate = LanguageVersionSettingsImpl(languageVersion, apiVersion)
|
||||||
|
|
||||||
@@ -37,7 +38,8 @@ data class CompilerTestLanguageVersionSettings(
|
|||||||
languageFeatures[feature] ?:
|
languageFeatures[feature] ?:
|
||||||
delegate.getFeatureSupport(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> {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,7 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.checkers
|
package org.jetbrains.kotlin.checkers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
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.ConfigurationKind
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
import org.jetbrains.kotlin.test.MockLibraryUtil
|
import org.jetbrains.kotlin.test.MockLibraryUtil
|
||||||
@@ -61,7 +64,12 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
|
|||||||
|
|
||||||
override fun loadLanguageVersionSettings(module: List<TestFile>): LanguageVersionSettings {
|
override fun loadLanguageVersionSettings(module: List<TestFile>): LanguageVersionSettings {
|
||||||
val analysisFlags = loadAnalysisFlags(module)
|
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?> {
|
private fun loadAnalysisFlags(module: List<TestFile>): Map<AnalysisFlag<*>, Any?> {
|
||||||
|
|||||||
Reference in New Issue
Block a user