[Test] Move KotlinAgainstKotlin tests under BlackBoxCodegen tests
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Ann
|
||||
|
||||
interface Tr {
|
||||
@Ann
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
class C : a.Tr
|
||||
|
||||
fun box(): String {
|
||||
val method = C::class.java.getDeclaredMethod("foo")
|
||||
val annotations = method.getDeclaredAnnotations().joinToString("\n")
|
||||
if (annotations != "@a.Ann()") {
|
||||
return "Fail: $annotations"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Anno(val value: String)
|
||||
|
||||
class Foo
|
||||
|
||||
typealias MyFoo = Foo
|
||||
typealias MyMaybeFoo = Foo?
|
||||
|
||||
class C<T>(val t: T)
|
||||
|
||||
typealias MyCMyFoo = C<@Anno("OK") MyFoo?>
|
||||
typealias MyCMaybeFoo = C<@Anno("OK") MyMaybeFoo>
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
fun testMyFoo(myc: MyCMyFoo) {}
|
||||
fun testMyMaybeFoo(mycmyb: MyCMaybeFoo) {}
|
||||
|
||||
fun box(): String {
|
||||
testMyFoo(C(null))
|
||||
testMyMaybeFoo(C(null))
|
||||
|
||||
for (fn in listOf(::testMyFoo, ::testMyMaybeFoo)) {
|
||||
val mycType = fn.parameters.single().type
|
||||
val argumentType = mycType.arguments.single().type!!
|
||||
if (!argumentType.isMarkedNullable)
|
||||
return "Fail on $fn: argument type should be seen as nullable"
|
||||
|
||||
val annotations = argumentType.annotations
|
||||
if (annotations.toString() != "[@Anno(value=OK)]")
|
||||
return "Fail on $fn: $annotations"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package a
|
||||
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
import kotlin.annotation.AnnotationRetention.*
|
||||
import java.lang.Class
|
||||
|
||||
@Target(TYPEALIAS)
|
||||
@Retention(RUNTIME)
|
||||
annotation class Ann(val x: Int)
|
||||
|
||||
@Ann(2)
|
||||
typealias TA = Any
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import a.Ann
|
||||
|
||||
fun Class<*>.assertHasDeclaredMethodWithAnn() {
|
||||
if (!declaredMethods.any { it.isSynthetic && it.getAnnotation(Ann::class.java) != null }) {
|
||||
throw java.lang.AssertionError("Class ${this.simpleName} has no declared method with annotation @Ann")
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Class.forName("a.AKt").assertHasDeclaredMethodWithAnn()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class Foo(val x: IntArray) {
|
||||
val size: Int get() = x.size
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String {
|
||||
val a = Foo(intArrayOf(3, 4))
|
||||
if (a.size != 2) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
@Suppress("UNSUPPORTED_FEATURE")
|
||||
inline class Foo(val x: IntArray) {
|
||||
val size: Int get() = x.size
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String {
|
||||
val a = Foo(intArrayOf(3, 4))
|
||||
if (a.size != 2) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
fun foo(): String = "OK"
|
||||
const val constOK: String = "OK"
|
||||
val valOK: String = "OK"
|
||||
var varOK: String = "Hmmm?"
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo() != "OK") return "Fail function"
|
||||
if (constOK != "OK") return "Fail const"
|
||||
if (valOK != "OK") return "Fail val"
|
||||
varOK = "OK"
|
||||
if (varOK != "OK") return "Fail var"
|
||||
return varOK
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// ^ TODO decide if we want to fix KT-42020 for FIR as well
|
||||
// MODULE: lib
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
open class Base<T> {
|
||||
fun foo(x: T) = "x:$x"
|
||||
fun foo(y: String) = "y:$y"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: b.kt
|
||||
import a.Base
|
||||
|
||||
open class Derived : Base<String>()
|
||||
|
||||
fun box(): String {
|
||||
val b = Base<String>()
|
||||
val test1 = b.foo(x = "O") + b.foo(y = "K")
|
||||
if (test1 != "x:Oy:K")
|
||||
throw Exception("test1: $test1")
|
||||
|
||||
val d = Derived()
|
||||
val test2 = d.foo(x = "O") + d.foo(y = "K")
|
||||
if (test2 != "x:Oy:K")
|
||||
throw Exception("test2: $test2")
|
||||
|
||||
val bd: Base<String> = Derived()
|
||||
val test4 = bd.foo(x = "O") + bd.foo(y = "K")
|
||||
if (test4 != "x:Oy:K")
|
||||
throw Exception("test4: $test4")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
object CartRoutes {
|
||||
class RemoveOrderItem {
|
||||
val result = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.CartRoutes
|
||||
|
||||
fun box(): String {
|
||||
val r = CartRoutes.RemoveOrderItem()
|
||||
return r.result
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package library
|
||||
|
||||
public enum class EnumClass {
|
||||
ENTRY;
|
||||
|
||||
public companion object {
|
||||
public fun entry(): EnumClass = ENTRY
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import library.EnumClass
|
||||
|
||||
fun box(): String {
|
||||
return if (EnumClass.entry() != EnumClass.ENTRY) "Fail" else "OK"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
class A {
|
||||
companion object {
|
||||
fun foo() = 42
|
||||
val bar = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
if (A.foo() != 42) return "Fail foo"
|
||||
return A.bar
|
||||
}
|
||||
compiler/testData/codegen/box/compileKotlinAgainstKotlin/constPropertyReferenceFromMultifileClass.kt
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:[JvmName("MultifileClass") JvmMultifileClass]
|
||||
package a
|
||||
|
||||
annotation class A
|
||||
|
||||
@A
|
||||
const val OK: String = "OK"
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.OK
|
||||
|
||||
fun box(): String {
|
||||
val okRef = ::OK
|
||||
|
||||
val annotations = okRef.annotations
|
||||
if (annotations.size != 1) {
|
||||
throw AssertionError("Failed, annotations: $annotations")
|
||||
}
|
||||
|
||||
return okRef.get()
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
class A(vararg s: String) {
|
||||
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
A()
|
||||
A("a")
|
||||
A("a", "b")
|
||||
return "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package lib
|
||||
|
||||
inline class S(val string: String)
|
||||
|
||||
class Test(val s: S)
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import lib.*
|
||||
|
||||
fun box() = Test(S("OK")).s.string
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
package lib
|
||||
|
||||
inline class S(val string: String)
|
||||
|
||||
class Test(val s: S)
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import lib.*
|
||||
|
||||
fun box() = Test(S("OK")).s.string
|
||||
@@ -0,0 +1,33 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// FULL_JDK
|
||||
|
||||
package test
|
||||
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
class A(val callable: Callable<String>)
|
||||
|
||||
inline fun doWork(noinline job: () -> String): Callable<String> {
|
||||
val a = A(Callable(job))
|
||||
return a.callable
|
||||
}
|
||||
|
||||
var sameModule = doWork { "O" }
|
||||
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val anotherModule = doWork { "K" }
|
||||
|
||||
if (sameModule.javaClass.name == anotherModule.javaClass.name) return "class should be regenerated, but ${anotherModule.javaClass.name}"
|
||||
if (sameModule.javaClass.name.contains("inlined")) return "Sam in same module shouldn't be copied, but ${sameModule.javaClass.name}"
|
||||
if (!anotherModule.javaClass.name.contains("inlined")) return "Sam in another module should be copied, but ${sameModule.javaClass.name}"
|
||||
|
||||
return sameModule.call() + anotherModule.call()
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// FULL_JDK
|
||||
|
||||
package test
|
||||
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
inline fun doWork(noinline job: () -> String): Callable<String> {
|
||||
return Callable(job)
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val anotherModule = doWork { "K" }
|
||||
|
||||
if (anotherModule.javaClass.name != "BKt\$inlined\$sam\$i\$java_util_concurrent_Callable\$0") return "class should be regenerated, but ${anotherModule.javaClass.name}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
package a
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class Controller {
|
||||
var callback: () -> Unit = {}
|
||||
suspend fun suspendHere() = suspendCoroutine<String> { x ->
|
||||
callback = {
|
||||
x.resume("OK")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend Controller.() -> Unit) {
|
||||
val controller = Controller()
|
||||
c.startCoroutine(controller, object : helpers.ContinuationAdapter<Unit>() {
|
||||
override val context: CoroutineContext = EmptyCoroutineContext
|
||||
override fun resume(value: Unit) {}
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {}
|
||||
})
|
||||
|
||||
controller.callback()
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import a.builder
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
builder {
|
||||
result = suspendHere()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package aaa
|
||||
|
||||
class A(val a: Int = 1)
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
aaa.A()
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun test(s: () -> () -> String = { val z = "Outer"; { "OK" } }) =
|
||||
s()
|
||||
|
||||
val same = test()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val inlined = test()
|
||||
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
|
||||
println (inlined::class.java)
|
||||
return inlined()
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun test(s: () -> () -> () -> String = { val z = "Outer"; { { "OK" } } }) =
|
||||
s()
|
||||
|
||||
val same = test()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val inlined = test()
|
||||
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
|
||||
if (same()::class.java == inlined()::class.java) return "fail 2 : ${same()::class.java} == ${inlined()::class.java}"
|
||||
return inlined()()
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package z
|
||||
|
||||
inline class Z(val s: String)
|
||||
|
||||
class X {
|
||||
fun Int.foo(z: Z, value: String = "OK") = value
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import z.*
|
||||
|
||||
fun box(): String = with(X()) { 1.foo(Z("")) }
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
package z
|
||||
|
||||
inline class Z(val s: String)
|
||||
|
||||
class X {
|
||||
fun Int.foo(z: Z, value: String = "OK") = value
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import z.*
|
||||
|
||||
fun box(): String = with(X()) { 1.foo(Z("")) }
|
||||
@@ -0,0 +1,19 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package lib
|
||||
|
||||
interface A {
|
||||
fun f(x: String = "OK"): String
|
||||
}
|
||||
|
||||
class B : A {
|
||||
override fun f(x: String) = x
|
||||
}
|
||||
|
||||
class C(val x: A) : A by x
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import lib.*
|
||||
|
||||
fun box() = C(B()).f()
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
interface A {
|
||||
@Throws(IOException::class)
|
||||
@Anno
|
||||
fun foo()
|
||||
}
|
||||
|
||||
annotation class Anno
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
class B(a: A) : A by a
|
||||
|
||||
fun box(): String {
|
||||
val method = B::class.java.declaredMethods.single { it.name == B::foo.name }
|
||||
if (method.exceptionTypes.size != 0)
|
||||
return "Fail throws: ${method.exceptionTypes.toList()}"
|
||||
|
||||
if (method.declaredAnnotations.size != 1)
|
||||
return "Fail annotations: ${method.declaredAnnotations.toList()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package aaa
|
||||
|
||||
class A {
|
||||
class B {
|
||||
class O {
|
||||
val s = "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
val str = aaa.A.B.O().s
|
||||
return str
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package aaa
|
||||
|
||||
enum class E {
|
||||
TRIVIAL_ENTRY,
|
||||
SUBCLASS { }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import aaa.E
|
||||
|
||||
fun box(): String {
|
||||
if (E.TRIVIAL_ENTRY == E.SUBCLASS) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: lib
|
||||
// FILE: impl.kt
|
||||
class A(val result: String = "OK")
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: multiplatform.kt
|
||||
expect class B(result: String = "FAIL")
|
||||
|
||||
actual typealias B = A
|
||||
|
||||
fun box(): String {
|
||||
return B().result
|
||||
}
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package a
|
||||
|
||||
interface T {
|
||||
var x: String
|
||||
}
|
||||
|
||||
interface A : T {
|
||||
override var x: String
|
||||
}
|
||||
|
||||
interface B : T {
|
||||
override var x: String
|
||||
}
|
||||
|
||||
class C : A, B {
|
||||
override var x: String = ""
|
||||
}
|
||||
|
||||
class D : A, B {
|
||||
override var x: String = ""
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import a.*
|
||||
|
||||
fun foo(condition: Boolean): String {
|
||||
val aAndB = if (condition) C() else D()
|
||||
aAndB.x = "OK"
|
||||
|
||||
return aAndB.x
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (foo(true) != "OK") return "fail 1"
|
||||
if (foo(false) != "OK") return "fail 2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
abstract class A {
|
||||
private val x = object {
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
protected val y = x.foo()
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
class B : A() {
|
||||
val z = y
|
||||
}
|
||||
|
||||
fun box() = B().z
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
interface KotlinMangler<D : Any> {
|
||||
val String.hashMangle: Long
|
||||
val D.fqnString: String
|
||||
val D.fqnMangle: Long get() = fqnString.hashMangle
|
||||
val manglerName: String
|
||||
|
||||
interface IrMangler : KotlinMangler<String> {
|
||||
override val manglerName: String
|
||||
get() = "Ir"
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractKotlinMangler<D : Any> : KotlinMangler<D> {
|
||||
override val String.hashMangle get() = 42L
|
||||
}
|
||||
|
||||
abstract class IrBasedKotlinManglerImpl : AbstractKotlinMangler<String>(), KotlinMangler.IrMangler {
|
||||
override val String.fqnString: String
|
||||
get() = this
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
abstract class AbstractJvmManglerIr : IrBasedKotlinManglerImpl()
|
||||
|
||||
object JvmManglerIr : AbstractJvmManglerIr()
|
||||
|
||||
fun box() = "OK"
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class IncrementalCompilerRunner<T>(
|
||||
private val workingDir: String,
|
||||
val fail: Boolean,
|
||||
val output: Collection<String> = emptyList()
|
||||
) {
|
||||
fun res(res: T? = null): String = (res as? String) ?: (if (fail) "FAIL" else workingDir)
|
||||
}
|
||||
|
||||
class IncrementalJsCompilerRunner(
|
||||
private val workingDir: String,
|
||||
fail: Boolean = true
|
||||
) : IncrementalCompilerRunner<String>(workingDir, fail) {
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
val runner = IncrementalJsCompilerRunner(workingDir = "OK", fail = false)
|
||||
return runner.res()
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// WITH_RUNTIME
|
||||
|
||||
abstract class IrConst<T> : IrExpression(), IrExpressionWithCopy {
|
||||
abstract val kind: IrConstKind<T>
|
||||
abstract val value: T
|
||||
|
||||
abstract override fun copy(): IrConst<T>
|
||||
abstract fun copyWithOffsets(startOffset: Int, endOffset: Int): IrConst<T>
|
||||
}
|
||||
|
||||
sealed class IrConstKind<T>(val asString: kotlin.String) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun valueOf(aConst: IrConst<*>) =
|
||||
(aConst as IrConst<T>).value
|
||||
|
||||
object Null : IrConstKind<Nothing?>("Null")
|
||||
object Boolean : IrConstKind<kotlin.Boolean>("Boolean")
|
||||
object Char : IrConstKind<kotlin.Char>("Char")
|
||||
object Byte : IrConstKind<kotlin.Byte>("Byte")
|
||||
object Short : IrConstKind<kotlin.Short>("Short")
|
||||
object Int : IrConstKind<kotlin.Int>("Int")
|
||||
object Long : IrConstKind<kotlin.Long>("Long")
|
||||
object String : IrConstKind<kotlin.String>("String")
|
||||
object Float : IrConstKind<kotlin.Float>("Float")
|
||||
object Double : IrConstKind<kotlin.Double>("Double")
|
||||
|
||||
override fun toString() = asString
|
||||
}
|
||||
|
||||
interface IrType
|
||||
|
||||
abstract class IrExpression : IrElementBase(), IrStatement, IrVarargElement, IrAttributeContainer {
|
||||
@Suppress("LeakingThis")
|
||||
override var attributeOwnerId: IrAttributeContainer = this
|
||||
|
||||
abstract var type: IrType
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpression =
|
||||
accept(transformer, data) as IrExpression
|
||||
|
||||
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
|
||||
// No children by default
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
// No children by default
|
||||
}
|
||||
}
|
||||
|
||||
interface IrExpressionWithCopy {
|
||||
fun copy(): IrExpression
|
||||
}
|
||||
|
||||
interface IrAttributeContainer : IrElement {
|
||||
var attributeOwnerId: IrAttributeContainer
|
||||
}
|
||||
|
||||
abstract class IrElementBase : IrElement
|
||||
|
||||
interface IrStatement : IrElement
|
||||
|
||||
interface IrVarargElement : IrElement
|
||||
|
||||
interface IrElement {
|
||||
val startOffset: Int
|
||||
val endOffset: Int
|
||||
|
||||
fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R
|
||||
|
||||
fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D): Unit
|
||||
|
||||
fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrElement =
|
||||
accept(transformer, data)
|
||||
|
||||
fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D): Unit
|
||||
}
|
||||
|
||||
interface IrElementVisitor<out R, in D>
|
||||
|
||||
interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D>
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun foo(cases: Collection<IrConst<*>>, exprTransformer: IrElementTransformer<Any>, context: Any) {
|
||||
cases.map {
|
||||
it.accept(exprTransformer, context)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
// WITH_RUNTIME
|
||||
|
||||
package first.second
|
||||
|
||||
class FqName(val s: String)
|
||||
|
||||
@JvmField
|
||||
val VOLATILE_ANNOTATION_FQ_NAME = FqName("volatile")
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import first.second.VOLATILE_ANNOTATION_FQ_NAME
|
||||
import first.second.FqName
|
||||
|
||||
fun foo() = hasAnnotation(VOLATILE_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun hasAnnotation(name: FqName): Boolean = true
|
||||
|
||||
fun box() = if (foo()) "OK" else "FAIL"
|
||||
@@ -0,0 +1,19 @@
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
class C(val x: String) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val instance: C = C("OK")
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
import test.C.Companion.instance
|
||||
|
||||
fun box() = instance.x
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
abstract class A {
|
||||
fun foo(s: String) = IC(s)
|
||||
}
|
||||
|
||||
open class C : A()
|
||||
|
||||
class D: C()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
fun box(): String {
|
||||
var res = C().foo("OK").s
|
||||
if (res != "OK") return "FAIL 1 $res"
|
||||
res = D().foo("OK").s
|
||||
return res
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: 1.kt
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
abstract class A {
|
||||
fun foo(s: String) = IC(s)
|
||||
}
|
||||
|
||||
open class C : A()
|
||||
|
||||
class D: C()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
fun box(): String {
|
||||
var res = C().foo("OK").s
|
||||
if (res != "OK") return "FAIL 1 $res"
|
||||
res = D().foo("OK").s
|
||||
return res
|
||||
}
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package z
|
||||
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
inline class Z(val s: String) : IFoo {
|
||||
constructor(i: Int) : this(i.toString())
|
||||
|
||||
override fun foo(): String = s
|
||||
|
||||
fun bar() = s
|
||||
|
||||
inline fun <T> run(lambda: (String) -> T) = lambda(s)
|
||||
|
||||
companion object {
|
||||
fun z(i: Int) = Z(i)
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import z.*
|
||||
|
||||
fun test(z: Z) {
|
||||
if (z.foo() != "1234") throw AssertionError()
|
||||
if (z.bar() != "1234") throw AssertionError()
|
||||
if (z.run { it } != "1234") throw AssertionError()
|
||||
if (listOf(z)[0].s != "1234") throw AssertionError()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(Z("1234"))
|
||||
test(Z(1234))
|
||||
test(Z.z(1234))
|
||||
return "OK"
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_STDLIB
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
package z
|
||||
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
inline class Z(val s: String) : IFoo {
|
||||
constructor(i: Int) : this(i.toString())
|
||||
|
||||
override fun foo(): String = s
|
||||
|
||||
fun bar() = s
|
||||
|
||||
inline fun <T> run(lambda: (String) -> T) = lambda(s)
|
||||
|
||||
companion object {
|
||||
fun z(i: Int) = Z(i)
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import z.*
|
||||
|
||||
fun test(z: Z) {
|
||||
if (z.foo() != "1234") throw AssertionError()
|
||||
if (z.bar() != "1234") throw AssertionError()
|
||||
if (z.run { it } != "1234") throw AssertionError()
|
||||
if (listOf(z)[0].s != "1234") throw AssertionError()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(Z("1234"))
|
||||
test(Z(1234))
|
||||
test(Z.z(1234))
|
||||
return "OK"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
inline class A(val x: String) {
|
||||
inline fun f(other: A): A = other
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return A("Fail").f(A("OK")).x
|
||||
}
|
||||
compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlineClassInlineFunctionCallOldMangling.kt
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
|
||||
inline class A(val x: String) {
|
||||
inline fun f(other: A): A = other
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return A("Fail").f(A("OK")).x
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
inline class S(val value: String) {
|
||||
inline val k: String
|
||||
get() = value + "K"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return a.S("O").k
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// MODULE: lib
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
inline class S(val value: String) {
|
||||
inline val k: String
|
||||
get() = value + "K"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return a.S("O").k
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// KOTLIN_CONFIGURATION_FLAGS: +JVM.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME
|
||||
package test
|
||||
|
||||
inline class IC(val s: String)
|
||||
|
||||
fun ordinary(s: String, ic: IC): String = s + ic.s
|
||||
|
||||
suspend fun suspend(s: String, ic: IC): String = s + ic.s
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
import kotlin.coroutines.*
|
||||
import test.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = ordinary("O", IC("K"))
|
||||
if (res != "OK") return "FAIL 1: $res"
|
||||
builder {
|
||||
res = suspend("O", IC("K"))
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package constants
|
||||
|
||||
public const val b: Byte = 100
|
||||
public const val s: Short = 20000
|
||||
public const val i: Int = 2000000
|
||||
public const val l: Long = 2000000000000L
|
||||
public const val f: Float = 3.14f
|
||||
public const val d: Double = 3.14
|
||||
public const val bb: Boolean = true
|
||||
public const val c: Char = '\u03c0' // pi symbol
|
||||
|
||||
public const val str: String = ":)"
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
public annotation class AnnotationClass(public val value: String)
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import constants.*
|
||||
|
||||
@AnnotationClass("$b $s $i $l $f $d $bb $c $str")
|
||||
class DummyClass()
|
||||
|
||||
fun box(): String {
|
||||
val klass = DummyClass::class.java
|
||||
val annotationClass = AnnotationClass::class.java
|
||||
val annotation = klass.getAnnotation(annotationClass)!!
|
||||
val value = annotation.value
|
||||
require(value == "100 20000 2000000 2000000000000 3.14 3.14 true \u03c0 :)", { "Annotation value: $value" })
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package second
|
||||
|
||||
public class Outer() {
|
||||
inner class Inner(test: String)
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
//test for KT-3702 Inner class constructor cannot be invoked in override function with receiver
|
||||
import second.Outer
|
||||
|
||||
fun Outer.testExt() {
|
||||
Inner("test")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Outer().testExt()
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package test
|
||||
|
||||
interface CodeBlock {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface CompositeCodeBlock: CodeBlock {
|
||||
override fun foo(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
interface ForLoopBody : CodeBlock
|
||||
|
||||
abstract class CodeBlockBase: CompositeCodeBlock
|
||||
|
||||
abstract class LineSeparatedCodeBlock: CodeBlockBase()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
open class KotlinCodeBlock: LineSeparatedCodeBlock()
|
||||
|
||||
class KotlinForLoopBody : KotlinCodeBlock(), ForLoopBody
|
||||
|
||||
fun box(): String {
|
||||
return KotlinForLoopBody().foo()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
abstract class Base {
|
||||
abstract var x: String
|
||||
internal set
|
||||
}
|
||||
|
||||
class Derived: Base() {
|
||||
override var x: String = "Z"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
fun box(): String {
|
||||
val d = Derived()
|
||||
d.x = "OK"
|
||||
return d.x
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
class Box() {
|
||||
internal fun result(value: String = "OK"): String = value
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return a.Box().result()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
inline class Message(val value: String)
|
||||
|
||||
class Box {
|
||||
internal fun result(msg: Message): String = msg.value
|
||||
}
|
||||
|
||||
// MODULE: main()(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return a.Box().result(a.Message("OK"))
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
class Box(val value: String) {
|
||||
internal fun result(): String = value
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return a.Box("OK").result()
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package a
|
||||
|
||||
interface IrSymbol {
|
||||
val owner: Any
|
||||
}
|
||||
|
||||
interface IrFunction
|
||||
interface IrSimpleFunction : IrFunction {
|
||||
val name: String
|
||||
}
|
||||
|
||||
interface IrFunctionSymbol : IrSymbol {
|
||||
override val owner: IrFunction
|
||||
}
|
||||
|
||||
interface IrBindableSymbol<B : Any> : IrSymbol {
|
||||
override val owner: B
|
||||
}
|
||||
|
||||
interface IrSimpleFunctionSymbol : IrFunctionSymbol, IrBindableSymbol<IrSimpleFunction>
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
import a.*
|
||||
|
||||
fun foo(x: IrSimpleFunctionSymbol): String {
|
||||
return x.owner.name
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return foo(object : IrSimpleFunctionSymbol {
|
||||
override val owner: IrSimpleFunction
|
||||
get() = object : IrSimpleFunction {
|
||||
override val name: String
|
||||
get() = "OK"
|
||||
}
|
||||
})
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// FULL_JDK
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface KInterface {
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
fun superCall() = Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
interface KInterface2 : KInterface {
|
||||
|
||||
}
|
||||
|
||||
class Foo: KInterface2 {
|
||||
fun superCall2() = super<KInterface2>.superCall()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = Foo().call()
|
||||
if (result[1] != "KInterface.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "MainKt.box") return "fail 2: ${result[2]}"
|
||||
|
||||
result = Foo().superCall2()
|
||||
if (result[1] != "KInterface.superCall") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "Foo.superCall2") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "MainKt.box") return "fail 3: ${result[3]}"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun delegatedTest(): String {
|
||||
return "fail"
|
||||
}
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override fun test(): String {
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
override fun delegatedTest(): String {
|
||||
return "K"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test() + testClass.delegatedTest()
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val test: String
|
||||
get() = "O"
|
||||
|
||||
val testDelegated: String
|
||||
get() = "fail"
|
||||
|
||||
}
|
||||
|
||||
class Delegate : Test {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
override val testDelegated: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass(val foo: Test) : Test by foo
|
||||
|
||||
fun box(): String {
|
||||
val testClass = TestClass(Delegate())
|
||||
return testClass.test + testClass.testDelegated
|
||||
}
|
||||
compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvm8/defaults/allCompatibility/superCall.kt
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.test()
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun defaultImplTrigger(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.test()
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass : Test {
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().prop
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
|
||||
val defaultImplTrigger: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
interface Check {
|
||||
fun test(): String {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
interface SubCheck : Check {
|
||||
override fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
open class CheckClass : Check
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
class SubCheckClass : CheckClass(), SubCheck
|
||||
|
||||
fun box(): String {
|
||||
return SubCheckClass().test()
|
||||
}
|
||||
compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvm8/defaults/interop/likeSpecialization.kt
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// JVM_TARGET: 1.8
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
|
||||
interface Foo<T> {
|
||||
fun test(p: T) = p
|
||||
val T.prop: String
|
||||
get() = "K"
|
||||
}
|
||||
|
||||
interface FooDerived: Foo<String>
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
open class UnspecializedFromDerived : FooDerived
|
||||
|
||||
fun box(): String {
|
||||
val foo = UnspecializedFromDerived()
|
||||
return foo.test("O") + with(foo) { "K".prop }
|
||||
}
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface KInterface {
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
fun superCall() = Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
interface KInterface2 : KInterface {
|
||||
override fun superCall() = super.superCall()
|
||||
}
|
||||
|
||||
interface KInterface3 : KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
class Foo: KInterface3 {
|
||||
fun superCall2() = super<KInterface3>.superCall()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = Foo().call()
|
||||
if (result[1] != "KInterface\$DefaultImpls.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface2\$DefaultImpls.call") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "KInterface3\$DefaultImpls.call") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "Foo.call") return "fail 4: ${result[4]}"
|
||||
if (result[5] != "MainKt.box") return "fail 5: ${result[5]}"
|
||||
|
||||
result = Foo().superCall2()
|
||||
if (result[1] != "KInterface\$DefaultImpls.superCall") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface2.superCall") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "Foo.superCall2") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "MainKt.box") return "fail 4: ${result[4]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
|
||||
interface Foo<T> {
|
||||
fun test(p: T) = "fail"
|
||||
val T.prop: String
|
||||
get() = "fail"
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
interface Foo2: Foo<String> {
|
||||
override fun test(p: String) = p
|
||||
|
||||
override val String.prop: String
|
||||
get() = this
|
||||
}
|
||||
|
||||
interface Foo3: Foo<String>, Foo2
|
||||
|
||||
class Base : Foo3
|
||||
|
||||
fun box(): String {
|
||||
val base = Base()
|
||||
return base.test("O") + with(base) { "K".prop }
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
|
||||
interface Foo<T> {
|
||||
fun test(p: T) = "fail"
|
||||
val T.prop: String
|
||||
get() = "fail"
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// JVM_TARGET: 1.8
|
||||
interface Foo2: Foo<String> {
|
||||
override fun test(p: String) : String = p
|
||||
|
||||
override val String.prop: String
|
||||
get() = this
|
||||
}
|
||||
|
||||
interface Foo3: Foo<String>, Foo2
|
||||
|
||||
class Base : Foo3
|
||||
|
||||
fun box(): String {
|
||||
val base = Base()
|
||||
return base.test("O") + with(base) { "K".prop }
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: disable
|
||||
interface KInterface {
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
interface KInterface2 : KInterface {
|
||||
|
||||
}
|
||||
|
||||
class Foo: KInterface2 {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = Foo().call()
|
||||
if (result[1] != "KInterface\$DefaultImpls.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface2\$DefaultImpls.call") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "Foo.call") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "MainKt.box") return "fail 4: ${result[4]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FULL_JDK
|
||||
// WITH_RUNTIME
|
||||
// JVM_TARGET: 1.8
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
interface KInterface {
|
||||
@JvmDefault
|
||||
fun call(): List<String> {
|
||||
return Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
fun superCall() = Thread.currentThread().getStackTrace().map { it.className + "." + it.methodName }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
interface KInterface2 : KInterface {
|
||||
override fun superCall() = super.superCall()
|
||||
}
|
||||
|
||||
class Foo: KInterface2 {
|
||||
fun superCall2() = super<KInterface2>.superCall()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = Foo().call()
|
||||
if (result[1] != "KInterface.call") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "MainKt.box") return "fail 2: ${result[2]}"
|
||||
|
||||
result = Foo().superCall2()
|
||||
if (result[1] != "KInterface\$DefaultImpls.superCall") return "fail 1: ${result[1]}"
|
||||
if (result[2] != "KInterface2.superCall") return "fail 2: ${result[2]}"
|
||||
if (result[3] != "Foo.superCall2") return "fail 3: ${result[3]}"
|
||||
if (result[4] != "MainKt.box") return "fail 4: ${result[4]}"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.test()
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun defaultImplTrigger(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.test()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
class TestClass : Test {
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().prop
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
@JvmDefault
|
||||
val prop: String
|
||||
get() = "OK"
|
||||
|
||||
val defaultImplTrigger: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val prop: String
|
||||
get() = super.prop
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : Test2 {}.prop
|
||||
}
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test3 : Test {
|
||||
override fun test(): String
|
||||
}
|
||||
|
||||
|
||||
interface Test4 : Test2, Test3 {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test4 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
open class TestClass : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String
|
||||
}
|
||||
|
||||
|
||||
class TestClass2 : TestClass(), Test2 {
|
||||
override fun test(): String {
|
||||
return super<TestClass>.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "fail"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
abstract class TestClass : Test {
|
||||
abstract override fun test(): String
|
||||
}
|
||||
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestClass2 : TestClass(), Test2 {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass2().test()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// SKIP_JDK6
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
import java.util.*
|
||||
class Jdk6List<F> : AbstractList<F>() {
|
||||
override fun get(index: Int): F {
|
||||
return "OK" as F
|
||||
}
|
||||
|
||||
override val size: Int
|
||||
get() = 2
|
||||
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
// FULL_JDK
|
||||
|
||||
fun box(): String {
|
||||
val result = Jdk6List<String>().stream().filter { it == "OK" }.count()
|
||||
if (result != 2L) return "fai1: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class TestClass : Test {
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
interface Test3 : Test2 {
|
||||
|
||||
}
|
||||
class TestClass : Test3
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override fun test(): String {
|
||||
return super.test()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestClass : Test2 {
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
val test: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
class TestClass : Test {
|
||||
override val test: String
|
||||
get() = super.test
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: enable
|
||||
// MODULE: lib
|
||||
// FILE: 1.kt
|
||||
|
||||
interface Test {
|
||||
val test: String
|
||||
get() = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: 2.kt
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
interface Test2 : Test {
|
||||
@JvmDefault
|
||||
override val test: String
|
||||
get() = super.test
|
||||
}
|
||||
|
||||
|
||||
class TestClass : Test2 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
return TestClass().test
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
open class A {
|
||||
@JvmField public val publicField = "1";
|
||||
@JvmField internal val internalField = "2";
|
||||
@JvmField protected val protectedfield = "3";
|
||||
}
|
||||
|
||||
open class B : A() {
|
||||
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
open class C : B() {
|
||||
fun test(): String {
|
||||
return publicField + super.internalField + super.protectedfield
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
C().test()
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface +NestedClassesInAnnotations
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
annotation class Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
open class A(@JvmField public val publicField: String = "1",
|
||||
@JvmField internal val internalField: String = "2",
|
||||
@JvmField protected val protectedfield: String = "3")
|
||||
|
||||
open class B : A()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
open class C : B() {
|
||||
fun test(): String {
|
||||
return publicField + super.internalField + super.protectedfield
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
C().test()
|
||||
return "OK"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +JvmFieldInInterface
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: Foo.kt
|
||||
|
||||
public class Bar(public val value: String)
|
||||
|
||||
interface Foo {
|
||||
companion object {
|
||||
@JvmField
|
||||
val FOO = Bar("OK")
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: bar.kt
|
||||
|
||||
fun box(): String {
|
||||
return Foo.FOO.value
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package lib
|
||||
|
||||
@JvmName("bar")
|
||||
fun foo() = "foo"
|
||||
|
||||
var v: Int = 1
|
||||
@JvmName("vget")
|
||||
get
|
||||
@JvmName("vset")
|
||||
set
|
||||
|
||||
fun consumeInt(x: Int) {}
|
||||
|
||||
open class A {
|
||||
val OK: String = "OK"
|
||||
@JvmName("OK") get
|
||||
|
||||
@JvmName("g")
|
||||
fun <T> f(x: T, y: Int = 1) = x
|
||||
}
|
||||
|
||||
annotation class Anno(@get:JvmName("uglyJvmName") val value: String)
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import lib.*
|
||||
|
||||
class B : A()
|
||||
|
||||
@Anno("OK")
|
||||
fun annotated() {}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
v = 1
|
||||
consumeInt(v)
|
||||
|
||||
val annoValue = (::annotated.annotations.single() as Anno).value
|
||||
if (annoValue != "OK") return "Fail annotation value: $annoValue"
|
||||
|
||||
val b = B()
|
||||
if (b.f("OK") != "OK") return "Fail call of annotated method"
|
||||
|
||||
return A().OK
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@file:JvmPackageName("bar")
|
||||
package foo
|
||||
|
||||
fun f() = "OK"
|
||||
|
||||
var v: Int = 1
|
||||
|
||||
inline fun i(block: () -> Unit) = block()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box(): String {
|
||||
v = 2
|
||||
if (v != 2) return "Fail"
|
||||
i { v = 3 }
|
||||
if (v != 3) return "Fail"
|
||||
return f()
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@file:JvmPackageName("bar")
|
||||
|
||||
fun f() = "OK"
|
||||
|
||||
var v: Int = 1
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
v = 2
|
||||
if (v != 2) return "Fail"
|
||||
return f()
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||
@file:JvmPackageName("baz.foo.quux.bar")
|
||||
@file:JvmName("Facade")
|
||||
@file:JvmMultifileClass
|
||||
package foo.bar
|
||||
|
||||
typealias S = String
|
||||
|
||||
fun f(): String = "O"
|
||||
|
||||
val g: S? get() = f().substring(0, 0) + "K"
|
||||
|
||||
inline fun <T> i(block: () -> T): T = block()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import foo.bar.*
|
||||
|
||||
fun box(): S = i { f() + g }
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@file:JvmPackageName("bar")
|
||||
@file:JvmName("Baz")
|
||||
package foo
|
||||
|
||||
fun f() = "OK"
|
||||
|
||||
var v: Int = 1
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import foo.*
|
||||
|
||||
fun box(): String {
|
||||
v = 2
|
||||
if (v != 2) return "Fail"
|
||||
return f()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package aaa
|
||||
|
||||
import kotlin.jvm.*
|
||||
|
||||
public object TestObject {
|
||||
@JvmStatic
|
||||
public val test: String = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return aaa.TestObject.test
|
||||
}
|
||||
Vendored
+61
@@ -0,0 +1,61 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
object Host {
|
||||
var none: Int = 0
|
||||
get() = field
|
||||
set(value) { field = value }
|
||||
|
||||
var get: Int = 0
|
||||
@JvmStatic
|
||||
get() = field
|
||||
set(value) { field = value }
|
||||
|
||||
var set: Int = 0
|
||||
get() = field
|
||||
@JvmStatic
|
||||
set(value) { field = value }
|
||||
|
||||
var both: Int = 0
|
||||
@JvmStatic
|
||||
get() = field
|
||||
@JvmStatic
|
||||
set(value) { field = value }
|
||||
|
||||
@JvmStatic
|
||||
var property: Int = 0
|
||||
get() = field
|
||||
set(value) { field = value }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun box(): String {
|
||||
val none = Host::none as KMutableProperty0<Int>
|
||||
none.set(1)
|
||||
if (none.get() != 1) return "Fail none: ${none.get()}"
|
||||
|
||||
val get = Host::get as KMutableProperty0<Int>
|
||||
get.set(1)
|
||||
if (get.get() != 1) return "Fail get: ${get.get()}"
|
||||
|
||||
val set = Host::set as KMutableProperty0<Int>
|
||||
set.set(1)
|
||||
if (set.get() != 1) return "Fail set: ${set.get()}"
|
||||
|
||||
val both = Host::both as KMutableProperty0<Int>
|
||||
both.set(1)
|
||||
if (both.get() != 1) return "Fail both: ${both.get()}"
|
||||
|
||||
val property = Host::property as KMutableProperty0<Int>
|
||||
property.set(1)
|
||||
if (property.get() != 1) return "Fail property: ${property.get()}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
package a
|
||||
|
||||
const val i = 2
|
||||
const val s = 2.toShort()
|
||||
const val f = 2.0.toFloat()
|
||||
const val d = 2.0
|
||||
const val l = 2L
|
||||
const val b = 2.toByte()
|
||||
const val bool = true
|
||||
const val c = 'c'
|
||||
const val str = "str"
|
||||
|
||||
const val i2 = i
|
||||
const val s2 = s
|
||||
const val f2 = f
|
||||
const val d2 = d
|
||||
const val l2 = l
|
||||
const val b2 = b
|
||||
const val bool2 = bool
|
||||
const val c2 = c
|
||||
const val str2 = str
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import a.*
|
||||
|
||||
@Ann(i, s, f, d, l, b, bool, c, str)
|
||||
class MyClass1
|
||||
|
||||
@Ann(i2, s2, f2, d2, l2, b2, bool2, c2, str2)
|
||||
class MyClass2
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Ann(
|
||||
val i: Int,
|
||||
val s: Short,
|
||||
val f: Float,
|
||||
val d: Double,
|
||||
val l: Long,
|
||||
val b: Byte,
|
||||
val bool: Boolean,
|
||||
val c: Char,
|
||||
val str: String
|
||||
)
|
||||
|
||||
fun box(): String {
|
||||
// Trigger annotation loading
|
||||
(MyClass1() as java.lang.Object).getClass().getAnnotations()
|
||||
(MyClass2() as java.lang.Object).getClass().getAnnotations()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
package test
|
||||
|
||||
var property = "fail"
|
||||
private set
|
||||
|
||||
fun test() {
|
||||
property = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
test()
|
||||
return property
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
@file:JvmName("TTest")
|
||||
@file:JvmMultifileClass
|
||||
package test
|
||||
|
||||
var property = "fail"
|
||||
private set
|
||||
|
||||
fun test() {
|
||||
property = "OK"
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
test()
|
||||
return property
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
class TestObserver<T> {
|
||||
fun assertValue(valuePredicate: (T) -> Boolean): Unit = TODO()
|
||||
}
|
||||
|
||||
class Single<T> {
|
||||
fun test(): TestObserver<T> = TODO()
|
||||
}
|
||||
|
||||
class Employee
|
||||
|
||||
class Either<T>
|
||||
|
||||
typealias DomainEither<T> = Either<T>
|
||||
typealias DomainSingle<T> = Single<DomainEither<T>>
|
||||
|
||||
fun provideDomainSingle(): DomainSingle<Employee> = TODO()
|
||||
|
||||
class CreateEmployeeUseCaseAccessor {
|
||||
fun testNormalName() {
|
||||
val testObs = provideDomainSingle().test()
|
||||
testObs.assertValue { true }
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
import lib.*
|
||||
|
||||
class CreateEmployeeUseCaseTest {
|
||||
fun testNormalName() {
|
||||
val testObs = provideDomainSingle().test()
|
||||
testObs.assertValue { true }
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
class A {
|
||||
val o = object {
|
||||
@JvmName("jvmGetO")
|
||||
fun getO(): String = "O"
|
||||
}
|
||||
|
||||
val k = object {
|
||||
@get:JvmName("jvmGetK")
|
||||
val k: String = "K"
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import kotlin.reflect.full.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val obj1 = a.o
|
||||
val o = obj1::class.declaredMemberFunctions.single().call(obj1) as String
|
||||
val obj2 = a.k
|
||||
val k = obj2::class.declaredMemberProperties.single().call(obj2) as String
|
||||
return o + k
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:[JvmName("Test") JvmMultifileClass]
|
||||
|
||||
val property = "K"
|
||||
|
||||
inline fun K(body: () -> String): String =
|
||||
body() + property
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
fun box(): String {
|
||||
return K { "O" }
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// MODULE: lib
|
||||
// FILE: A.kt
|
||||
|
||||
@file:[JvmName("Test") JvmMultifileClass]
|
||||
|
||||
typealias S = String
|
||||
typealias LS = List<S>
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: B.kt
|
||||
|
||||
import java.util.Arrays
|
||||
|
||||
fun box(): S {
|
||||
val l: LS = Arrays.asList("OK")
|
||||
return l[0]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user