Update error about unsupported language and API versions

Set first supported version to 1.3
Add property for oldest depecated language version in order to control unsupported ones
Report error on attempts to manually disable language feature from unsupported versions
Update test data, drop compatibility tests for features from unsupported versions

KT-36146 In progress
This commit is contained in:
Pavel Kirpichenkov
2020-01-27 17:06:08 +03:00
parent 715e7e1a3c
commit 913ed71863
75 changed files with 337 additions and 305 deletions
@@ -426,6 +426,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
private fun HashMap<LanguageFeature, LanguageFeature.State>.configureLanguageFeaturesFromInternalArgs(collector: MessageCollector) {
val featuresThatForcePreReleaseBinaries = mutableListOf<LanguageFeature>()
val disabledFeaturesFromUnsupportedVersions = mutableListOf<LanguageFeature>()
var standaloneSamConversionFeaturePassedExplicitly = false
var functionReferenceWithDefaultValueFeaturePassedExplicitly = false
@@ -435,6 +436,10 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
featuresThatForcePreReleaseBinaries += feature
}
if (state == LanguageFeature.State.DISABLED && feature.sinceVersion?.isUnsupported == true) {
disabledFeaturesFromUnsupportedVersions += feature
}
when (feature) {
LanguageFeature.SamConversionPerArgument ->
standaloneSamConversionFeaturePassedExplicitly = true
@@ -460,6 +465,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
"Following manually enabled features will force generation of pre-release binaries: ${featuresThatForcePreReleaseBinaries.joinToString()}"
)
}
if (disabledFeaturesFromUnsupportedVersions.isNotEmpty()) {
collector.report(
CompilerMessageSeverity.ERROR,
"The following features cannot be disabled manually, because the version they first appeared in is no longer " +
"supported:\n${disabledFeaturesFromUnsupportedVersions.joinToString()}"
)
}
}
fun toLanguageVersionSettings(collector: MessageCollector): LanguageVersionSettings {
@@ -471,32 +484,77 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
// (API version cannot be greater than the language version)
val apiVersion = parseVersion(collector, apiVersion, "API") ?: languageVersion
checkApiVersionIsNotGreaterThenLanguageVersion(languageVersion, apiVersion, collector)
checkLanguageVersionIsStable(languageVersion, collector)
checkOutdatedVersions(languageVersion, apiVersion, collector)
checkProgressiveMode(languageVersion, collector)
val languageVersionSettings = LanguageVersionSettingsImpl(
languageVersion,
ApiVersion.createByLanguageVersion(apiVersion),
configureAnalysisFlags(collector),
configureLanguageFeatures(collector)
)
checkCoroutines(languageVersionSettings, collector)
return languageVersionSettings
}
private fun checkApiVersionIsNotGreaterThenLanguageVersion(
languageVersion: LanguageVersion,
apiVersion: LanguageVersion,
collector: MessageCollector
) {
if (apiVersion > languageVersion) {
collector.report(
CompilerMessageSeverity.ERROR,
"-api-version (${apiVersion.versionString}) cannot be greater than -language-version (${languageVersion.versionString})"
)
}
}
private fun checkLanguageVersionIsStable(languageVersion: LanguageVersion, collector: MessageCollector) {
if (!languageVersion.isStable) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"Language version ${languageVersion.versionString} is experimental, there are no backwards compatibility guarantees for new language and library features"
"Language version ${languageVersion.versionString} is experimental, there are no backwards compatibility guarantees for " +
"new language and library features"
)
}
}
val deprecatedVersion = when {
languageVersion < LanguageVersion.FIRST_SUPPORTED -> "Language version ${languageVersion.versionString}"
apiVersion < LanguageVersion.FIRST_SUPPORTED -> "API version ${apiVersion.versionString}"
private fun checkOutdatedVersions(language: LanguageVersion, api: LanguageVersion, collector: MessageCollector) {
val (version, versionKind) = findOutdatedVersion(language, api) ?: return
when {
version.isUnsupported -> {
collector.report(
CompilerMessageSeverity.ERROR,
"${versionKind.text} version ${version.versionString} is no longer supported; " +
"please, use version ${LanguageVersion.OLDEST_DEPRECATED.versionString} or greater."
)
}
version.isDeprecated -> {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"${versionKind.text} version ${version.versionString} is deprecated " +
"and its support will be removed in a future version of Kotlin"
)
}
}
}
private fun findOutdatedVersion(language: LanguageVersion, api: LanguageVersion): Pair<LanguageVersion, VersionKind>? {
return when {
language.isUnsupported -> language to VersionKind.LANGUAGE
api.isUnsupported -> api to VersionKind.API
language.isDeprecated -> language to VersionKind.LANGUAGE
api.isDeprecated -> api to VersionKind.API
else -> null
}
if (deprecatedVersion != null) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
"$deprecatedVersion is deprecated and its support will be removed in a future version of Kotlin"
)
}
}
private fun checkProgressiveMode(languageVersion: LanguageVersion, collector: MessageCollector) {
if (progressiveMode && languageVersion < LanguageVersion.LATEST_STABLE) {
collector.report(
CompilerMessageSeverity.STRONG_WARNING,
@@ -506,14 +564,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
"or turning off progressive mode."
)
}
}
val languageVersionSettings = LanguageVersionSettingsImpl(
languageVersion,
ApiVersion.createByLanguageVersion(apiVersion),
configureAnalysisFlags(collector),
configureLanguageFeatures(collector)
)
private fun checkCoroutines(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)) {
if (coroutinesState != DEFAULT) {
collector.report(
@@ -522,19 +575,21 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
}
}
}
return languageVersionSettings
private enum class VersionKind(val text: String) {
LANGUAGE("Language"), API("API")
}
private fun parseVersion(collector: MessageCollector, value: String?, versionOf: String): LanguageVersion? =
if (value == null) null
else LanguageVersion.fromVersionString(value)
?: run {
val versionStrings = LanguageVersion.values().map(LanguageVersion::description)
val message = "Unknown $versionOf version: $value\nSupported $versionOf versions: ${versionStrings.joinToString(", ")}"
collector.report(CompilerMessageSeverity.ERROR, message, null)
null
}
?: run {
val versionStrings = LanguageVersion.values().map(LanguageVersion::description)
val message = "Unknown $versionOf version: $value\nSupported $versionOf versions: ${versionStrings.joinToString(", ")}"
collector.report(CompilerMessageSeverity.ERROR, message, null)
null
}
// Used only for serialize and deserialize settings. Don't use in other places!
class DummyImpl : CommonCompilerArguments()
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/languageVersion.kt
-output
$TEMP_DIR$/out.js
-language-version
1.2
1.3
+6 -2
View File
@@ -1,5 +1,9 @@
package test
annotation class Outer {
class Nested
fun test() {
while (true) {
when {
true -> break
}
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
compiler/testData/cli/js/languageVersion.kt:4:5: error: members are not allowed in annotation class
class Nested
^
compiler/testData/cli/js/languageVersion.kt:6:21: error: 'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop
true -> break
^
COMPILATION_ERROR
@@ -0,0 +1,7 @@
$TESTDATA_DIR$/apiAndLanguageVersionsUnsupported.kt
-d
$TEMP_DIR$
-language-version
1.1
-api-version
1.0
@@ -0,0 +1 @@
class Test
@@ -0,0 +1,2 @@
error: language version 1.1 is no longer supported; please, use version 1.2 or greater.
COMPILATION_ERROR
+13 -2
View File
@@ -1,3 +1,14 @@
fun test() {
""::class.sealedSubclasses
class A
fun foo(
p00: A, p01: A, p02: A, p03: A, p04: A, p05: A, p06: A, p07: A, p08: A, p09: A,
p10: A, p11: A, p12: A, p13: A, p14: A, p15: A, p16: A, p17: A, p18: A, p19: A,
p20: A, p21: A, p22: A, p23: A, p24: A, p25: A, p26: A, p27: A, p28: A, p29: A
) {}
fun bar(x: Any) {}
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
bar(::foo)
bar(x)
}
+7 -3
View File
@@ -1,4 +1,8 @@
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
""::class.sealedSubclasses
^
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion.kt:11:20: error: the feature "function types with big arity" is only available since API version 1.3
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
^
compiler/testData/cli/jvm/apiVersion.kt:12:9: error: the feature "function types with big arity" is only available since API version 1.3
bar(::foo)
^
COMPILATION_ERROR
-7
View File
@@ -1,7 +0,0 @@
$TESTDATA_DIR$/apiVersion1.0.kt
-d
$TEMP_DIR$
-language-version
1.1
-api-version
1.0
-16
View File
@@ -1,16 +0,0 @@
typealias Foo = Int
sealed class A
data class B(val foo: Int): A()
inline val f get() = ""
suspend fun test() {
""::class
""::toString
Foo::class
Foo::toString
val b by lazy { "" }
}
-14
View File
@@ -1,14 +0,0 @@
warning: language version 1.1 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion1.0.kt:8:1: error: the feature "coroutines" is only available since API version 1.1 (see: https://kotlinlang.org/docs/diagnostics/experimental-coroutines)
suspend fun test() {
^
compiler/testData/cli/jvm/apiVersion1.0.kt:9:5: error: the feature "bound callable references" is only available since API version 1.1
""::class
^
compiler/testData/cli/jvm/apiVersion1.0.kt:10:5: error: the feature "bound callable references" is only available since API version 1.1
""::toString
^
compiler/testData/cli/jvm/apiVersion1.0.kt:15:11: error: the feature "local delegated properties" is only available since API version 1.1
val b by lazy { "" }
^
COMPILATION_ERROR
@@ -1,3 +1,4 @@
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersionAndSinceNewerKotlin.kt:4:1: warning: the version is greater than the specified API version 1.2
@SinceKotlin("1.3")
^
@@ -2,6 +2,6 @@ $TESTDATA_DIR$/apiVersion.kt
-d
$TEMP_DIR$
-api-version
1.3
1.4
-language-version
1.2
1.3
@@ -1,2 +1,2 @@
error: -api-version (1.3) cannot be greater than -language-version (1.2)
error: -api-version (1.4) cannot be greater than -language-version (1.3)
COMPILATION_ERROR
+7 -3
View File
@@ -1,4 +1,8 @@
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
""::class.sealedSubclasses
^
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion.kt:11:20: error: the feature "function types with big arity" is only available since API version 1.3
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
^
compiler/testData/cli/jvm/apiVersion.kt:12:9: error: the feature "function types with big arity" is only available since API version 1.3
bar(::foo)
^
COMPILATION_ERROR
@@ -1,4 +1,8 @@
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
""::class.sealedSubclasses
^
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion.kt:11:20: error: the feature "function types with big arity" is only available since API version 1.3
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
^
compiler/testData/cli/jvm/apiVersion.kt:12:9: error: the feature "function types with big arity" is only available since API version 1.3
bar(::foo)
^
COMPILATION_ERROR
+5
View File
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/apiVersionUnsupported.kt
-d
$TEMP_DIR$
-api-version
1.1
+1
View File
@@ -0,0 +1 @@
class Test
+2
View File
@@ -0,0 +1,2 @@
error: API version 1.1 is no longer supported; please, use version 1.2 or greater.
COMPILATION_ERROR
+7 -3
View File
@@ -1,6 +1,10 @@
warning: flag is not supported by this version of the compiler: -Xdouble ' quote ' escaped " sequence /
warning: flag is not supported by this version of the compiler: -Xsingle " quote " escaped ' sequence /
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
""::class.sealedSubclasses
^
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion.kt:11:20: error: the feature "function types with big arity" is only available since API version 1.3
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
^
compiler/testData/cli/jvm/apiVersion.kt:12:9: error: the feature "function types with big arity" is only available since API version 1.3
bar(::foo)
^
COMPILATION_ERROR
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/simple.kt
-d
$TEMP_DIR$
-api-version
1.1
1.2
+1 -1
View File
@@ -1,2 +1,2 @@
warning: API version 1.1 is deprecated and its support will be removed in a future version of Kotlin
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
OK
@@ -0,0 +1,7 @@
$TESTDATA_DIR$/deprecatedLanguageUnsupportedApi.kt
-d
$TEMP_DIR$
-language-version
1.2
-api-version
1.1
@@ -0,0 +1 @@
class Test
@@ -0,0 +1,2 @@
error: API version 1.1 is no longer supported; please, use version 1.2 or greater.
COMPILATION_ERROR
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/simple.kt
-d
$TEMP_DIR$
-language-version
1.1
1.2
+1 -1
View File
@@ -1,2 +1,2 @@
warning: language version 1.1 is deprecated and its support will be removed in a future version of Kotlin
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
OK
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/disabledFeatureInUnsupportedVersion.kt
-XXLanguage\:-TypeAliases
-XXLanguage\:-BoundCallableReferences
-d
$TEMP_DIR$
@@ -0,0 +1 @@
class Test
@@ -0,0 +1,13 @@
warning: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:-TypeAliases
-XXLanguage:-BoundCallableReferences
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
error: the following features cannot be disabled manually, because the version they first appeared in is no longer supported:
TypeAliases, BoundCallableReferences
COMPILATION_ERROR
@@ -1,6 +1,6 @@
$TESTDATA_DIR$/legacySmartCastsAfterTry.kt
$TESTDATA_DIR$/variableInWhenSubject.kt
-d
$TEMP_DIR$
-language-version
1.1
-XXLanguage\:+SoundSmartCastsAfterTry
1.2
-XXLanguage\:+VariableDeclarationInWhenSubject
@@ -1,14 +1,11 @@
warning: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+SoundSmartCastsAfterTry
-XXLanguage:+VariableDeclarationInWhenSubject
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
warning: language version 1.1 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/legacySmartCastsAfterTry.kt:8:9: error: only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?
some.length
^
COMPILATION_ERROR
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
OK
@@ -2,5 +2,5 @@ $TESTDATA_DIR$/simple.kt
-d
$TEMP_DIR$
-language-version
1.2
-XXLanguage\:+ProhibitDataClassesOverridingCopy
1.3
-XXLanguage\:+RestrictReturnStatementTarget
+1
View File
@@ -1 +1,2 @@
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
OK
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/languageVersion.kt
-d
$TEMP_DIR$
-language-version
1.2
1.3
+6 -2
View File
@@ -1,5 +1,9 @@
package test
annotation class Outer {
class Nested
fun test() {
while (true) {
when {
true -> break
}
}
}
+3 -3
View File
@@ -1,4 +1,4 @@
compiler/testData/cli/jvm/languageVersion.kt:4:5: error: members are not allowed in annotation class
class Nested
^
compiler/testData/cli/jvm/languageVersion.kt:6:21: error: 'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop
true -> break
^
COMPILATION_ERROR
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/languageVersionUnsupported.kt
-d
$TEMP_DIR$
-language-version
1.1
@@ -0,0 +1 @@
class Test
@@ -0,0 +1,2 @@
error: language version 1.1 is no longer supported; please, use version 1.2 or greater.
COMPILATION_ERROR
+7 -3
View File
@@ -1,4 +1,8 @@
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: sealedSubclasses
""::class.sealedSubclasses
^
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/apiVersion.kt:11:20: error: the feature "function types with big arity" is only available since API version 1.3
fun test(vararg x: Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
^
compiler/testData/cli/jvm/apiVersion.kt:12:9: error: the feature "function types with big arity" is only available since API version 1.3
bar(::foo)
^
COMPILATION_ERROR
@@ -1,5 +0,0 @@
interface WithCopy<T> {
fun copy(str: T): WithCopy<T>
}
data class Test(val str: String): WithCopy<String>
@@ -1,6 +0,0 @@
val nonConstArray = longArrayOf(0)
annotation class Anno(vararg val value: Long)
@Anno(value = nonConstArray)
fun foo1() {}
@@ -0,0 +1,3 @@
open class A {
tailrec open fun foo(x: Int) {}
}
@@ -0,0 +1,3 @@
fun test() {
val x = object<T> { }
}
@@ -1,5 +0,0 @@
val my: Int = 1
get() {
field++
return field
}
+1 -1
View File
@@ -2,4 +2,4 @@ $TESTDATA_DIR$/progressive
-d
$TEMP_DIR$
-language-version
1.2
1.3
+11 -8
View File
@@ -1,10 +1,13 @@
compiler/testData/cli/jvm/progressive/dataClassOverridingCopy.kt:5:1: warning: function 'copy' generated for the data class has default values for parameters, and conflicts with member of supertype 'WithCopy'
data class Test(val str: String): WithCopy<String>
^
compiler/testData/cli/jvm/progressive/nonConstValueAsVarargInAnnotation.kt:5:15: warning: an annotation argument must be a compile-time constant
@Anno(value = nonConstArray)
^
compiler/testData/cli/jvm/progressive/valReassignmentViaBackingField.kt:3:9: warning: reassignment of read-only property via backing field is deprecated
field++
compiler/testData/cli/jvm/progressive/tailrecOnVirtualMember.kt:2:5: warning: a function is marked as tail-recursive but no tail calls are found
tailrec open fun foo(x: Int) {}
^
compiler/testData/cli/jvm/progressive/tailrecOnVirtualMember.kt:2:5: warning: tailrec on open members is deprecated
tailrec open fun foo(x: Int) {}
^
compiler/testData/cli/jvm/progressive/typeParametersInAnonymousObjects.kt:2:9: warning: variable 'x' is never used
val x = object<T> { }
^
compiler/testData/cli/jvm/progressive/typeParametersInAnonymousObjects.kt:2:19: warning: type parameters for anonymous objects are deprecated
val x = object<T> { }
^
OK
+6 -9
View File
@@ -1,10 +1,7 @@
compiler/testData/cli/jvm/progressive/dataClassOverridingCopy.kt:5:1: error: function 'copy' generated for the data class has default values for parameters, and conflicts with member of supertype 'WithCopy'
data class Test(val str: String): WithCopy<String>
^
compiler/testData/cli/jvm/progressive/nonConstValueAsVarargInAnnotation.kt:5:15: error: an annotation argument must be a compile-time constant
@Anno(value = nonConstArray)
^
compiler/testData/cli/jvm/progressive/valReassignmentViaBackingField.kt:3:9: error: reassignment of read-only property via backing field
field++
^
compiler/testData/cli/jvm/progressive/tailrecOnVirtualMember.kt:2:5: error: tailrec is not allowed on open members
tailrec open fun foo(x: Int) {}
^
compiler/testData/cli/jvm/progressive/typeParametersInAnonymousObjects.kt:2:19: error: type parameters are not allowed for objects
val x = object<T> { }
^
COMPILATION_ERROR
@@ -1,3 +1,4 @@
warning: API version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.kt:1:1: error: unsupported [cannot use release coroutines with api version less than 1.3]
suspend fun dummy() {}
^
-5
View File
@@ -1,5 +0,0 @@
-language-version
1.0
$TESTDATA_DIR$/unsupportedTypeAlias.kt
-d
$TEMP_DIR$
-3
View File
@@ -1,3 +0,0 @@
package test
typealias Unused = String
-5
View File
@@ -1,5 +0,0 @@
warning: language version 1.0 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/cli/jvm/unsupportedTypeAlias.kt:3:1: error: the feature "type aliases" is only available since language version 1.1
typealias Unused = String
^
COMPILATION_ERROR
+6
View File
@@ -0,0 +1,6 @@
$TESTDATA_DIR$/variableInWhenSubject.kt
-d
$TEMP_DIR$
-language-version
1.2
-XXLanguage\:+VariableDeclarationInWhenSubject
+5
View File
@@ -0,0 +1,5 @@
fun test(s: String?) =
when (val v = s) {
null -> ""
else -> v
}
+11
View File
@@ -0,0 +1,11 @@
warning: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+VariableDeclarationInWhenSubject
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
OK
@@ -1,31 +0,0 @@
package library
import kotlin.coroutines.experimental.*
var continuation: Continuation<Unit>? = null
val sb = java.lang.StringBuilder()
fun append(s: String) { sb.append(s) }
val libraryResult: String get() = sb.toString()
// this is an inline tail-suspend function that should work properly despite being compiler by
// compiler before 1.1.4 version that did not include suspension marks into bytecode.
// In order to test that it works properly it shall actually suspend during its execution
inline suspend fun foo(block: () -> Unit) {
append("(foo)")
block()
return suspendCoroutine<Unit> { continuation = it }
}
suspend fun bar() {
append("(bar)")
return suspendCoroutine<Unit> { continuation = it }
}
fun resumeLibrary() {
continuation?.let {
continuation = null
it.resume(Unit)
}
}
@@ -1,36 +0,0 @@
import library.*
import kotlin.coroutines.experimental.*
suspend fun test() {
append("[foo]")
foo { // we are inlining foo here
append("(block)")
}
append("[bar]")
bar() // and invoking suspending function bar
append("[test]")
}
fun runBlockingLibrary(block: suspend () -> Unit): String {
var done = false
block.startCoroutine(object : Continuation<Unit> {
override val context: CoroutineContext = EmptyCoroutineContext
override fun resume(value: Unit) { done = true }
override fun resumeWithException(exception: Throwable) { throw exception }
})
var resumeCounter = 0
while (!done) {
resumeCounter++
resumeLibrary()
}
return "$libraryResult:resumes=$resumeCounter"
}
// Retruns array of expected and received string
fun run(): Array<String> {
val result = runBlockingLibrary {
test()
}
return arrayOf("[foo](foo)(block)[bar](bar)[test]:resumes=2", result)
}
@@ -1,3 +1,4 @@
warning: language version 1.2 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/compileKotlinAgainstCustomBinaries/releaseCoroutineCallFromExperimental/experimental.kt:2:5: error: 'dummy(): Unit' is only available since Kotlin 1.3 and cannot be used in Kotlin 1.2
dummy()
^
@@ -1,37 +1,37 @@
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.3. This declaration is only supported since Kotlin 42.33
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.4. This declaration is only supported since Kotlin 42.33
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.4
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:13: error: 'A' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.4
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.3. This declaration is only supported since Kotlin 42.33
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.4. This declaration is only supported since Kotlin 42.33
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.4
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:3:17: error: 'typealias TA = String' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.4
fun test(a: A): TA {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.3. This declaration is only supported since Kotlin 42.33
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.4. This declaration is only supported since Kotlin 42.33
f()
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.4
f()
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:4:5: error: 'f(): Unit' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.4
f()
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.3. This declaration is only supported since Kotlin 42.33
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 42.33 and cannot be used in Kotlin 1.4. This declaration is only supported since Kotlin 42.33
return p
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 40.34 and cannot be used in Kotlin 1.4
return p
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlin/source.kt:5:12: error: 'p: String' is only available since Kotlin 45.35 and cannot be used in Kotlin 1.4
return p
^
COMPILATION_ERROR
@@ -1,7 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClasses/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClasses/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.4
fun test(a: Outer.Nested) {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClasses/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClasses/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.4
a.f()
^
COMPILATION_ERROR
@@ -1,7 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.4
fun test(a: Outer.Nested) {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.4
a.f()
^
COMPILATION_ERROR
@@ -1,7 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14Js/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14Js/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.4
fun test(a: Outer.Nested) {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14Js/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesAgainst14Js/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.4
a.f()
^
COMPILATION_ERROR
@@ -1,7 +1,7 @@
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesJs/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesJs/source.kt:3:19: error: 'Nested' is only available since Kotlin 1.44 and cannot be used in Kotlin 1.4
fun test(a: Outer.Nested) {
^
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesJs/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.3
compiler/testData/compileKotlinAgainstCustomBinaries/requireKotlinInNestedClassesJs/source.kt:4:7: error: 'f(): Unit' is only available since Kotlin 1.88 and cannot be used in Kotlin 1.4
a.f()
^
COMPILATION_ERROR
@@ -1,11 +0,0 @@
package test
typealias Str = String
typealias L<T> = List<T>
class Klass {
@Suppress("TOPLEVEL_TYPEALIASES_ONLY")
typealias Nested = Z
class Z
}
@@ -1,8 +0,0 @@
import test.*
import test.Str
fun use(
str: Str,
l: L<Str>,
nested: Klass.Nested
) {}
@@ -1,17 +0,0 @@
warning: language version 1.0 is deprecated and its support will be removed in a future version of Kotlin
compiler/testData/compileKotlinAgainstCustomBinaries/typeAliasesAreInvisibleInCompatibilityMode/main.kt:2:13: error: unresolved reference: Str
import test.Str
^
compiler/testData/compileKotlinAgainstCustomBinaries/typeAliasesAreInvisibleInCompatibilityMode/main.kt:5:14: error: unresolved reference: Str
str: Str,
^
compiler/testData/compileKotlinAgainstCustomBinaries/typeAliasesAreInvisibleInCompatibilityMode/main.kt:6:12: error: unresolved reference: L
l: L<Str>,
^
compiler/testData/compileKotlinAgainstCustomBinaries/typeAliasesAreInvisibleInCompatibilityMode/main.kt:6:14: error: unresolved reference: Str
l: L<Str>,
^
compiler/testData/compileKotlinAgainstCustomBinaries/typeAliasesAreInvisibleInCompatibilityMode/main.kt:7:23: error: unresolved reference: Nested
nested: Klass.Nested
^
COMPILATION_ERROR
@@ -3,9 +3,9 @@ Buildfile: [TestData]/build.xml
build:
[kotlinc] Compiling [[TestData]/main.kt] => [[Temp]/hello.jar]
[kotlinc] [TestData]/main.kt:2:5: error: members are not allowed in annotation class
[kotlinc] class Nested
[kotlinc] ^
[kotlinc] [TestData]/main.kt:4:21: error: 'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop
[kotlinc] true -> break
[kotlinc] ^
ERR:
@@ -3,7 +3,7 @@
<target name="build">
<kotlinc src="${test.data}/main.kt" output="${temp}/hello.jar">
<compilerarg line="-language-version 1.2"/>
<compilerarg line="-language-version 1.3"/>
</kotlinc>
</target>
</project>
@@ -1,3 +1,7 @@
annotation class Outer {
class Nested
fun test() {
while (true) {
when {
true -> break
}
}
}
+30 -10
View File
@@ -30,16 +30,16 @@ public class CliTestGenerated extends AbstractCliTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/cli/jvm"), Pattern.compile("^(.+)\\.args$"), null, false);
}
@TestMetadata("apiAndLanguageVersionsUnsupported.args")
public void testApiAndLanguageVersionsUnsupported() throws Exception {
runTest("compiler/testData/cli/jvm/apiAndLanguageVersionsUnsupported.args");
}
@TestMetadata("apiVersion.args")
public void testApiVersion() throws Exception {
runTest("compiler/testData/cli/jvm/apiVersion.args");
}
@TestMetadata("apiVersion1.0.args")
public void testApiVersion1_0() throws Exception {
runTest("compiler/testData/cli/jvm/apiVersion1.0.args");
}
@TestMetadata("apiVersionAndSinceNewerKotlin.args")
public void testApiVersionAndSinceNewerKotlin() throws Exception {
runTest("compiler/testData/cli/jvm/apiVersionAndSinceNewerKotlin.args");
@@ -65,6 +65,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/apiVersionLessThanLanguageUsingArgfile.args");
}
@TestMetadata("apiVersionUnsupported.args")
public void testApiVersionUnsupported() throws Exception {
runTest("compiler/testData/cli/jvm/apiVersionUnsupported.args");
}
@TestMetadata("argfileWithEmptyArgument.args")
public void testArgfileWithEmptyArgument() throws Exception {
runTest("compiler/testData/cli/jvm/argfileWithEmptyArgument.args");
@@ -160,6 +165,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/deprecatedApiVersion.args");
}
@TestMetadata("deprecatedLanguageUnsupportedApi.args")
public void testDeprecatedLanguageUnsupportedApi() throws Exception {
runTest("compiler/testData/cli/jvm/deprecatedLanguageUnsupportedApi.args");
}
@TestMetadata("deprecatedLanguageVersion.args")
public void testDeprecatedLanguageVersion() throws Exception {
runTest("compiler/testData/cli/jvm/deprecatedLanguageVersion.args");
@@ -170,6 +180,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/diagnosticsOrder.args");
}
@TestMetadata("disabledFeatureFromUnsupportedVersion.args")
public void testDisabledFeatureFromUnsupportedVersion() throws Exception {
runTest("compiler/testData/cli/jvm/disabledFeatureFromUnsupportedVersion.args");
}
@TestMetadata("duplicateSources.args")
public void testDuplicateSources() throws Exception {
runTest("compiler/testData/cli/jvm/duplicateSources.args");
@@ -480,6 +495,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/languageVersionInvalid.args");
}
@TestMetadata("languageVersionUnsupported.args")
public void testLanguageVersionUnsupported() throws Exception {
runTest("compiler/testData/cli/jvm/languageVersionUnsupported.args");
}
@TestMetadata("legacySmartCastsAfterTry.args")
public void testLegacySmartCastsAfterTry() throws Exception {
runTest("compiler/testData/cli/jvm/legacySmartCastsAfterTry.args");
@@ -645,16 +665,16 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/unknownExtraFlags.args");
}
@TestMetadata("unsupportedTypeAlias.args")
public void testUnsupportedTypeAlias() throws Exception {
runTest("compiler/testData/cli/jvm/unsupportedTypeAlias.args");
}
@TestMetadata("useMixedNamedArgumentsFlag.args")
public void testUseMixedNamedArgumentsFlag() throws Exception {
runTest("compiler/testData/cli/jvm/useMixedNamedArgumentsFlag.args");
}
@TestMetadata("variableInWhenSubject.args")
public void testVariableInWhenSubject() throws Exception {
runTest("compiler/testData/cli/jvm/variableInWhenSubject.args");
}
@TestMetadata("warningJdkWithNoJdk.args")
public void testWarningJdkWithNoJdk() throws Exception {
runTest("compiler/testData/cli/jvm/warningJdkWithNoJdk.args");
@@ -448,15 +448,6 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
compileKotlin("main.kt", tmpdir, listOf(library))
}
fun testTypeAliasesAreInvisibleInCompatibilityMode() {
val library = compileLibrary("library")
// -Xskip-metadata-version-check because if master is pre-release, an extra error will be reported when compiling with LV 1.0
// against a library compiled by a pre-release compiler
compileKotlin(
"main.kt", tmpdir, listOf(library), K2JVMCompiler(), listOf("-language-version", "1.0", "-Xskip-metadata-version-check")
)
}
fun testInnerClassPackageConflict() {
val output = compileLibrary("library", destination = File(tmpdir, "library"))
File(testDataDirectory, "library/test/Foo/x.txt").copyTo(File(output, "test/Foo/x.txt"))
@@ -248,6 +248,12 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware {
val isStable: Boolean
get() = this <= LATEST_STABLE
val isDeprecated: Boolean
get() = this >= OLDEST_DEPRECATED && this < FIRST_SUPPORTED
val isUnsupported: Boolean
get() = this < OLDEST_DEPRECATED
val versionString: String
get() = "$major.$minor"
@@ -265,7 +271,10 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware {
str.split(".", "-").let { if (it.size >= 2) fromVersionString("${it[0]}.${it[1]}") else null }
@JvmField
val FIRST_SUPPORTED = KOTLIN_1_2
val OLDEST_DEPRECATED = KOTLIN_1_2
@JvmField
val FIRST_SUPPORTED = KOTLIN_1_3
@JvmField
val LATEST_STABLE = KOTLIN_1_4