New test for jvm8 nondefaults target

This commit is contained in:
Mikhael Bogdanov
2017-01-12 16:14:05 +01:00
parent d278a5c6d5
commit 09eeb414fe
12 changed files with 315 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// JVM_TARGET: 1.8
interface Test<T> {
fun test(p: T): T {
return p
}
}
class TestClass : Test<String> {
override fun test(p: String): String {
return p + "K"
}
}
fun <T> execute(t: Test<T>, p: T): T {
return t.test(p)
}
fun box(): String {
return execute(TestClass(), "O")
}

View File

@@ -0,0 +1,24 @@
// JVM_TARGET: 1.8
interface Test<T> {
fun test(p: T): T {
return p
}
}
interface Test2: Test<String> {
override fun test(p: String): String {
return p + "K"
}
}
class TestClass : Test2 {
}
fun <T> execute(t: Test<T>, p: T): T {
return t.test(p)
}
fun box(): String {
return execute(TestClass(), "O")
}

View File

@@ -0,0 +1,13 @@
// JVM_TARGET: 1.8
interface Z {
fun test(s: String = "OK"): String {
return s
}
}
class Test: Z
fun box(): String {
return Test().test()
}

View File

@@ -0,0 +1,54 @@
// JVM_TARGET: 1.8
// WITH_RUNTIME
// IGNORE_BACKEND: JS
interface Z {
private fun privateFun() = { "OK" }
fun callPrivateFun() = privateFun()
fun publicFun() = { "OK" }
fun funWithDefaultArgs(s: () -> Unit = {}): () -> Unit
val property: () -> Unit
get() = {}
class Nested
}
class Test : Z {
override fun funWithDefaultArgs(s: () -> Unit): () -> Unit {
return s
}
}
fun box(): String {
val privateFun = Test().callPrivateFun()
var enclosing = privateFun.javaClass.enclosingMethod!!
if (enclosing.name != "privateFun") return "fail 1: ${enclosing.name}"
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 2: ${enclosing.getDeclaringClass().simpleName}"
val publicFun = Test().publicFun()
enclosing = publicFun.javaClass.enclosingMethod!!
if (enclosing.name != "publicFun") return "fail 3: ${enclosing.name}"
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 4: ${enclosing.getDeclaringClass().simpleName}"
val property = Test().property
enclosing = property.javaClass.enclosingMethod!!
if (enclosing.name != "getProperty") return "fail 4: ${enclosing.name}"
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 5: ${enclosing.getDeclaringClass().simpleName}"
val defaultArgs = Test().funWithDefaultArgs()
enclosing = defaultArgs.javaClass.enclosingMethod!!
if (enclosing.name != "funWithDefaultArgs\$default") return "fail 6: ${enclosing.name}"
if (enclosing.parameterTypes.size != 4) return "fail 7: not default method ${enclosing.name}"
if (enclosing.getDeclaringClass().simpleName != "DefaultImpls") return "fail 8: ${enclosing.getDeclaringClass().simpleName}"
val nested = Z.Nested::class.java
val enclosingClass = nested.enclosingClass!!
if (enclosingClass.name != "Z") return "fail 9: ${enclosingClass.name}"
return "OK"
}

View File

@@ -0,0 +1,20 @@
// JVM_TARGET: 1.8
interface Z<T> {
fun test(p: T): T {
return p
}
}
open class ZImpl : Z<String>
class ZImpl2 : ZImpl() {
override fun test(p: String): String {
return super.test(p)
}
}
fun box(): String {
return ZImpl2().test("OK")
}

View File

@@ -0,0 +1,22 @@
// JVM_TARGET: 1.8
interface Z<T> {
fun test(p: T): T {
return p
}
}
open class ZImpl : Z<String>
open class ZImpl2 : Z<String>, ZImpl()
class ZImpl3 : ZImpl2() {
override fun test(p: String): String {
return super.test(p)
}
}
fun box(): String {
return ZImpl3().test("OK")
}

View File

@@ -0,0 +1,23 @@
// JVM_TARGET: 1.8
interface Z<T> {
val value: T
val z: T
get() = value
}
open class ZImpl : Z<String> {
override val value: String
get() = "OK"
}
open class ZImpl2 : ZImpl() {
override val z: String
get() = super.z
}
fun box(): String {
return ZImpl2().value
}

View File

@@ -0,0 +1,20 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface KCallable {
val returnType: String
}
interface KCallableImpl : KCallable {
override val returnType: String
get() = "OK"
}
interface KCallableImpl2 : KCallableImpl
open class DescriptorBasedProperty : KCallableImpl
open class KProperty1Impl : DescriptorBasedProperty(), KCallableImpl2
open class KMutableProperty1Impl : KProperty1Impl(), KCallable
fun box(): String {
return KMutableProperty1Impl().returnType
}

View File

@@ -0,0 +1,24 @@
// JVM_TARGET: 1.8
interface KCallable {
val returnType: String
}
interface KCallableImpl : KCallable {
override val returnType: String
get() = "OK"
}
interface KProperty : KCallable
interface KPropertyImpl : KProperty, KCallableImpl
interface KMutableProperty : KProperty
interface KProperty1 : KProperty
interface KMutableProperty1 : KProperty1, KMutableProperty
interface KMutablePropertyImpl : KPropertyImpl
open class DescriptorBasedProperty : KCallableImpl
open class KProperty1Impl : DescriptorBasedProperty(), KProperty1, KPropertyImpl
open class KMutableProperty1Impl : KProperty1Impl(), KMutableProperty1, KMutablePropertyImpl
fun box(): String {
return KMutableProperty1Impl().returnType
}

View File

@@ -0,0 +1,15 @@
// JVM_TARGET: 1.8
interface Test {
fun test(): String {
return "OK"
}
}
class TestClass : Test {
}
fun box(): String {
return TestClass().test()
}

View File

@@ -0,0 +1,13 @@
// JVM_TARGET: 1.8
interface Z {
val z: String;
get() = "OK"
}
class Test : Z
fun box() : String {
return Test().z
}