Enable new inference feature by system property for tests only
This commit is contained in:
+1
-1
@@ -227,7 +227,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
}
|
||||
|
||||
return result ?: CompilerTestLanguageVersionSettings(
|
||||
BaseDiagnosticsTest.DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
|
||||
DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
|
||||
LanguageVersionSettingsImpl.DEFAULT.apiVersion,
|
||||
LanguageVersionSettingsImpl.DEFAULT.languageVersion
|
||||
)
|
||||
|
||||
@@ -141,7 +141,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
this.declareFlexibleType = EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE in directives
|
||||
this.markDynamicCalls = MARK_DYNAMIC_CALLS_DIRECTIVE in directives
|
||||
this.withNewInferenceDirective = WITH_NEW_INFERENCE_DIRECTIVE in directives
|
||||
this.newInferenceEnabled = (customLanguageVersionSettings ?: LanguageVersionSettingsImpl.DEFAULT).supportsFeature(LanguageFeature.NewInference)
|
||||
this.newInferenceEnabled = customLanguageVersionSettings?.supportsFeature(LanguageFeature.NewInference) ?: shouldUseNewInferenceForTests()
|
||||
if (fileName.endsWith(".java")) {
|
||||
// TODO: check there are no syntax errors in .java sources
|
||||
this.createKtFile = lazyOf(null)
|
||||
@@ -197,6 +197,11 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
return result
|
||||
}
|
||||
|
||||
private fun shouldUseNewInferenceForTests(): Boolean {
|
||||
if (System.getProperty("kotlin.ni") == "true") return true
|
||||
return LanguageVersionSettingsImpl.DEFAULT.supportsFeature(LanguageFeature.NewInference)
|
||||
}
|
||||
|
||||
fun getActualText(
|
||||
bindingContext: BindingContext,
|
||||
implementingModulesBindings: List<Pair<MultiTargetPlatform, BindingContext>>,
|
||||
@@ -277,8 +282,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
for (declaration in declarations) {
|
||||
val diagnostics = getJvmSignatureDiagnostics(declaration, bindingContext.diagnostics,
|
||||
GlobalSearchScope.allScope(project)) ?: continue
|
||||
val withNewInference = (customLanguageVersionSettings ?: LanguageVersionSettingsImpl.DEFAULT).supportsFeature(LanguageFeature.NewInference)
|
||||
jvmSignatureDiagnostics.addAll(diagnostics.forElement(declaration).map { ActualDiagnostic(it, null, withNewInference) })
|
||||
jvmSignatureDiagnostics.addAll(diagnostics.forElement(declaration).map { ActualDiagnostic(it, null, newInferenceEnabled) })
|
||||
}
|
||||
return jvmSignatureDiagnostics
|
||||
}
|
||||
|
||||
+12
-2
@@ -27,16 +27,26 @@ const val API_VERSION_DIRECTIVE = "API_VERSION"
|
||||
data class CompilerTestLanguageVersionSettings(
|
||||
private val languageFeatures: Map<LanguageFeature, LanguageFeature.State>,
|
||||
override val apiVersion: ApiVersion,
|
||||
override val languageVersion: LanguageVersion
|
||||
override val languageVersion: LanguageVersion,
|
||||
private val specificFeatures: Map<LanguageFeature, LanguageFeature.State> = specificFeaturesForTests()
|
||||
) : LanguageVersionSettings {
|
||||
private val delegate = LanguageVersionSettingsImpl(languageVersion, apiVersion)
|
||||
|
||||
override fun getFeatureSupport(feature: LanguageFeature): LanguageFeature.State =
|
||||
languageFeatures[feature] ?: delegate.getFeatureSupport(feature)
|
||||
specificFeatures[feature] ?:
|
||||
languageFeatures[feature] ?:
|
||||
delegate.getFeatureSupport(feature)
|
||||
|
||||
override fun <T> getFlag(flag: AnalysisFlag<T>): T = flag.defaultValue
|
||||
}
|
||||
|
||||
private fun specificFeaturesForTests(): Map<LanguageFeature, LanguageFeature.State> {
|
||||
return if (System.getProperty("kotlin.ni") == "true")
|
||||
mapOf(LanguageFeature.NewInference to LanguageFeature.State.ENABLED)
|
||||
else
|
||||
emptyMap()
|
||||
}
|
||||
|
||||
fun parseLanguageVersionSettings(directiveMap: Map<String, String>): LanguageVersionSettings? {
|
||||
val apiVersionString = directiveMap[API_VERSION_DIRECTIVE]
|
||||
val directives = directiveMap[LANGUAGE_DIRECTIVE]
|
||||
|
||||
Reference in New Issue
Block a user