'superConstructorCall' test folder moved under 'innerNested'
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
open class A(val s: String) {
|
||||
open inner class B(s: String): A(s)
|
||||
|
||||
open inner class C(s: String, additional: Double): B(s)
|
||||
|
||||
open inner class D(other: Int, another: Long, s: String) : C(s, another.toDouble())
|
||||
|
||||
open inner class E : D(0, 42L, "OK")
|
||||
|
||||
inner class F : E()
|
||||
}
|
||||
|
||||
fun box(): String = A("Fail").F().s
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
fun box(): String {
|
||||
abstract class L1 {
|
||||
abstract fun foo(): String
|
||||
}
|
||||
|
||||
open class L2(val s: String) : L1() {
|
||||
override fun foo() = s
|
||||
}
|
||||
|
||||
open class L3(unused: Double, value: String = "OK") : L2(value)
|
||||
|
||||
open class L4(i: Int, j: Long, z: Boolean, l: L3) : L3(3.14)
|
||||
|
||||
class L5 : L4(0, 0L, false, L3(2.71, "Fail"))
|
||||
|
||||
return L5().foo()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
open class Father(val param: String) {
|
||||
abstract inner class InClass {
|
||||
fun work(): String {
|
||||
return param
|
||||
}
|
||||
}
|
||||
|
||||
inner class Child(p: String) : Father(p) {
|
||||
inner class Child2 : Father.InClass {
|
||||
constructor(): super()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Father("fail").Child("OK").Child2().work()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
open class Father(val param: String) {
|
||||
abstract inner class InClass {
|
||||
fun work(): String {
|
||||
return param
|
||||
}
|
||||
}
|
||||
|
||||
inner class Child(p: String) : Father(p) {
|
||||
inner class Child2 : Father.InClass() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Father("fail").Child("OK").Child2().work()
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// When inner class extends its outer, there are two instances of the outer present in the inner:
|
||||
// the enclosing one and the one in the super call.
|
||||
// Here we test that symbols are resolved to the instance created via the super call.
|
||||
|
||||
open class Outer(vararg val chars: Char) {
|
||||
open inner class Inner(val s: String): Outer(s[0], s[1]) {
|
||||
fun concat() = java.lang.String.valueOf(chars)
|
||||
}
|
||||
|
||||
fun value() = Inner("OK").concat()
|
||||
}
|
||||
|
||||
fun box() = Outer('F', 'a', 'i', 'l').value()
|
||||
@@ -0,0 +1,17 @@
|
||||
abstract class Father {
|
||||
abstract inner class InClass {
|
||||
abstract fun work(): String
|
||||
}
|
||||
}
|
||||
|
||||
class Child : Father() {
|
||||
val ChildInClass = object : Father.InClass() {
|
||||
override fun work(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Child().ChildInClass.work()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
abstract class Father {
|
||||
abstract inner class InClass {
|
||||
abstract fun work(): String
|
||||
}
|
||||
}
|
||||
|
||||
class Child : Father() {
|
||||
fun test(): InClass {
|
||||
return object : Father.InClass() {
|
||||
override fun work(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Child().test().work()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
fun bar(): Any {
|
||||
return {
|
||||
{
|
||||
class Local : Inner() {
|
||||
override fun toString() = foo()
|
||||
}
|
||||
Local()
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
open inner class Inner
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = A().bar().toString()
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
open class Father(val param: String) {
|
||||
abstract inner class InClass {
|
||||
fun work(): String {
|
||||
return param
|
||||
}
|
||||
}
|
||||
|
||||
inner class Child(p: String) : Father(p) {
|
||||
fun test(): InClass {
|
||||
class Local : Father.InClass() {
|
||||
|
||||
}
|
||||
return Local()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Father("fail").Child("OK").test().work()
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
open class Local(val ok: Boolean) {
|
||||
fun result() = if (ok) result else "Fail"
|
||||
}
|
||||
|
||||
class Derived : Local(true)
|
||||
|
||||
return Derived().result()
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
fun box(): String {
|
||||
val three = 3
|
||||
|
||||
open class Local(val one: Int) {
|
||||
open fun value() = "$three$one"
|
||||
}
|
||||
|
||||
val four = 4
|
||||
|
||||
class Derived(val two: Int) : Local(1) {
|
||||
override fun value() = super.value() + "$four$two"
|
||||
}
|
||||
|
||||
val result = Derived(2).value()
|
||||
return if (result == "3142") "OK" else "Fail: $result"
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// KT-3581
|
||||
|
||||
open class A(val result: String = "OK") {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = object : A() {}
|
||||
return a.result
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
open class SomeClass(val some: Double, val other: Int, vararg val args: String) {
|
||||
fun result() = args[1]
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return object : SomeClass(3.14, 42, "No", "OK", "Yes") {
|
||||
}.result()
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
class A {
|
||||
open inner class Inner(val result: String)
|
||||
|
||||
fun box(): String {
|
||||
val o = object : Inner("OK") {
|
||||
fun ok() = result
|
||||
}
|
||||
return o.ok()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = A().box()
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
class A {
|
||||
open inner class Inner(val result: String = "OK", val int: Int)
|
||||
|
||||
fun box(): String {
|
||||
val o = object : Inner(int = 0) {
|
||||
fun ok() = result
|
||||
}
|
||||
return o.ok()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = A().box()
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
fun box(): String {
|
||||
val capture = "oh"
|
||||
|
||||
class Local {
|
||||
val captured = capture
|
||||
|
||||
open inner class Inner(val d: Double = -1.0, val s: String, vararg val y: Int) {
|
||||
open fun result() = "Fail"
|
||||
}
|
||||
|
||||
val obj = object : Inner(s = "OK") {
|
||||
override fun result() = s
|
||||
}
|
||||
}
|
||||
|
||||
return Local().obj.result()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
fun box(): String {
|
||||
class Local {
|
||||
open inner class Inner(val s: String) {
|
||||
open fun result() = "Fail"
|
||||
}
|
||||
|
||||
val realResult = "OK"
|
||||
|
||||
val obj = object : Inner(realResult) {
|
||||
override fun result() = s
|
||||
}
|
||||
}
|
||||
|
||||
return Local().obj.result()
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
open class A(val s: String)
|
||||
|
||||
fun box(): String {
|
||||
class B {
|
||||
val result = "OK"
|
||||
|
||||
val f = object : A(result) {}.s
|
||||
}
|
||||
|
||||
return B().f
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
fun box(): String {
|
||||
val d = 42.0
|
||||
val c = 'C'
|
||||
|
||||
open class Local(val l: Long) {
|
||||
fun foo(): Boolean = d == 42.0 && c == 'C' && l == 239L
|
||||
}
|
||||
|
||||
if (object : Local(239L) {
|
||||
fun bar(): Boolean = foo()
|
||||
}.bar()) return "OK"
|
||||
|
||||
return "Fail"
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
class A {
|
||||
fun bar(): Any {
|
||||
return {
|
||||
{
|
||||
object : Inner() {
|
||||
override fun toString() = foo()
|
||||
}
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
open inner class Inner
|
||||
fun foo() = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = A().bar().toString()
|
||||
Reference in New Issue
Block a user