[FE] Add test for compiling against library with kotlin sealed classes and interfaces
#KT-20423 #KT-13495
This commit is contained in:
committed by
TeamCityServer
parent
7897bb6adb
commit
c0a1aecf9b
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
interface IA : IBase
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package test
|
||||
|
||||
sealed class B : Base(), IBase {
|
||||
class First : B()
|
||||
class Second : B()
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
sealed interface IBase
|
||||
|
||||
sealed class Base
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
enum class C : IBase {
|
||||
SomeValue, AnotherValue
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package test
|
||||
|
||||
object D : Base(), IBase
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import test.*
|
||||
|
||||
fun test_1(base: IBase) {
|
||||
val x = when (base) {
|
||||
is IA -> 1
|
||||
is B -> 2
|
||||
is C -> 3
|
||||
is D -> 4
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: IBase) {
|
||||
val x = when (base) {
|
||||
is IA -> 1
|
||||
is B.First -> 2
|
||||
is B.Second -> 3
|
||||
C.SomeValue -> 4
|
||||
C.AnotherValue -> 5
|
||||
D -> 6
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(base: Base) {
|
||||
val x = when (base) {
|
||||
is B -> 2
|
||||
is D -> 4
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(base: Base) {
|
||||
val x = when (base) {
|
||||
is B.First -> 2
|
||||
is B.Second -> 3
|
||||
D -> 6
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+FreedomForSealedClasses
|
||||
-XXLanguage:+SealedInterfaces
|
||||
|
||||
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!
|
||||
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/main.kt:4:9: warning: variable 'x' is never used
|
||||
val x = when (base) {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/main.kt:13:9: warning: variable 'x' is never used
|
||||
val x = when (base) {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/main.kt:24:9: warning: variable 'x' is never used
|
||||
val x = when (base) {
|
||||
^
|
||||
compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/main.kt:31:9: warning: variable 'x' is never used
|
||||
val x = when (base) {
|
||||
^
|
||||
OK
|
||||
+6
@@ -694,6 +694,12 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
compileKotlin("source.kt", tmpdir, listOf(library), additionalOptions = listOf("-Xallow-jvm-ir-dependencies"))
|
||||
}
|
||||
|
||||
fun testSealedClassesAndInterfaces() {
|
||||
val features = listOf("-XXLanguage:+FreedomForSealedClasses", "-XXLanguage:+SealedInterfaces")
|
||||
val library = compileLibrary("library", additionalOptions = features, checkKotlinOutput = {})
|
||||
compileKotlin("main.kt", tmpdir, listOf(library), additionalOptions = features)
|
||||
}
|
||||
|
||||
// If this test fails, then bootstrap compiler most likely should be advanced
|
||||
fun testPreReleaseFlagIsConsistentBetweenBootstrapAndCurrentCompiler() {
|
||||
val bootstrapCompiler = JarFile(PathUtil.kotlinPathsForCompiler.compilerPath)
|
||||
|
||||
Reference in New Issue
Block a user