Correctly apply SAM conversions in superclass constructor calls

#KT-5452 Fixed
This commit is contained in:
Dmitry Jemerov
2015-03-25 15:13:47 +01:00
parent da9fe7d9a9
commit 827d9d48c1
16 changed files with 117 additions and 11 deletions

View File

@@ -0,0 +1,11 @@
class JavaClass {
private Runnable r;
public JavaClass(Runnable r) {
this.r = r;
}
public void run() {
r.run();
}
}

View File

@@ -0,0 +1,8 @@
var status: String = "fail" // global property to avoid issues with accessing closure from local class (KT-4174)
fun box(): String {
class C() : JavaClass({status = "OK"}) {}
C().run()
return status
}

View File

@@ -0,0 +1,11 @@
class JavaClass {
private Runnable r;
public JavaClass(Runnable r) {
this.r = r;
}
public void run() {
r.run();
}
}

View File

@@ -0,0 +1,6 @@
fun box(): String {
var v = "FAIL"
val x = object : JavaClass({-> v = "OK"}) {}
x.run()
return v
}

View File

@@ -0,0 +1,11 @@
class JavaClass {
private Runnable r;
public JavaClass(Runnable r) {
this.r = r;
}
public void run() {
r.run();
}
}

View File

@@ -0,0 +1,7 @@
fun box(): String {
var v = "FAIL"
val f = {-> v = "OK"}
val x = object : JavaClass(f) {}
x.run()
return v
}

View File

@@ -0,0 +1,5 @@
class JavaClass {
JavaClass(Runnable r) {
if (r != null) r.run();
}
}

View File

@@ -0,0 +1,9 @@
var status: String = "fail" // global property to avoid issues with accessing closure from local class (KT-4174)
class KotlinClass(): JavaClass({status="OK"}) {
}
fun box(): String {
KotlinClass()
return status
}