Introduce "-api-version" CLI option
The `@SinceKotlin("X.Y.Z")` annotation now hides a particular declaration from
resolution when the API version specified by the `-api-version` option is
_less_ than X.Y.Z. The comparison is performed as for versions in Maven:
MavenComparableVersion is in fact a copy of
org.apache.maven.artifact.versioning.ComparableVersion.
Also support "!API_VERSION" directive in diagnostic tests
#KT-14298 Fixed
This commit is contained in:
Vendored
+1
@@ -13,6 +13,7 @@ where possible options include:
|
||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||
-output-postfix <path> Path to file which will be added to the end of output file
|
||||
-language-version <version> Provide source compatibility with specified language version
|
||||
-api-version <version> Allow to use declarations only from the specified version of bundled libraries
|
||||
-nowarn Generate no warnings
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/apiVersion.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
1.0
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
""::class.isInstance(42)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: isInstance
|
||||
""::class.isInstance(42)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,7 @@
|
||||
$TESTDATA_DIR$/apiVersion.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
1.1
|
||||
-language-version
|
||||
1.0
|
||||
@@ -0,0 +1,2 @@
|
||||
error: -api-version (1.1) cannot be greater than -language-version (1.0)
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
239.42
|
||||
@@ -0,0 +1,3 @@
|
||||
error: unknown API version: 239.42
|
||||
Supported API versions: 1.0, 1.1
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,7 @@
|
||||
$TESTDATA_DIR$/apiVersion.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-api-version
|
||||
1.0
|
||||
-language-version
|
||||
1.1
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/apiVersion.kt:2:15: error: unresolved reference: isInstance
|
||||
""::class.isInstance(42)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
Vendored
+1
@@ -15,6 +15,7 @@ where possible options include:
|
||||
-module-name Module name
|
||||
-jvm-target <version> Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6
|
||||
-language-version <version> Provide source compatibility with specified language version
|
||||
-api-version <version> Allow to use declarations only from the specified version of bundled libraries
|
||||
-nowarn Generate no warnings
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
@@ -3,3 +3,7 @@ package test
|
||||
sealed class Base
|
||||
|
||||
class Derived : Base()
|
||||
|
||||
fun test() {
|
||||
""::class.isInstance(42)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
compiler/testData/cli/jvm/languageVersion.kt:5:17: error: this type is sealed, so it can be inherited by only its own nested classes or objects
|
||||
class Derived : Base()
|
||||
^
|
||||
compiler/testData/cli/jvm/languageVersion.kt:8:5: error: the feature is only available since Kotlin 1.1: bound callable references
|
||||
""::class.isInstance(42)
|
||||
^
|
||||
compiler/testData/cli/jvm/languageVersion.kt:8:15: error: unresolved reference: isInstance
|
||||
""::class.isInstance(42)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ where possible options include:
|
||||
-module-name Module name
|
||||
-jvm-target <version> Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6
|
||||
-language-version <version> Provide source compatibility with specified language version
|
||||
-api-version <version> Allow to use declarations only from the specified version of bundled libraries
|
||||
-nowarn Generate no warnings
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
Reference in New Issue
Block a user