Introduce Parameter: Java -> Kotlin Interoperability

This commit is contained in:
Alexey Sedunov
2015-04-14 20:09:15 +03:00
parent 93861e16c8
commit f13eb038e1
15 changed files with 376 additions and 11 deletions
@@ -0,0 +1,3 @@
fun test() {
val x = J().foo(1, 2, 3)
}
@@ -0,0 +1,3 @@
fun test() {
val x = J().foo(3, A(a + b))
}
@@ -0,0 +1,19 @@
class A {
int x;
A(int x) {
this.x = x;
}
}
class J {
int foo(int a, int b, int c) {
return <selection>new A(a + b)</selection>.x * c
}
}
class Test {
void test() {
new J().foo(1, 2, 3);
}
}
@@ -0,0 +1,19 @@
class A {
int x;
A(int x) {
this.x = x;
}
}
class J {
int foo(int c, A a1) {
return a1.x * c
}
}
class Test {
void test() {
new J().foo(3, new A(1 + 2));
}
}
@@ -0,0 +1,12 @@
fun test() {
J().foo(1, 2, 3)
K().foo(1, 2, 3)
}
abstract class K0 {
abstract fun foo(a: Int, b: Int, c: Int): Int
}
open class K: K0() {
override fun foo(a: Int, b: Int, c: Int) = a + b + c
}
@@ -0,0 +1,12 @@
fun test() {
J().foo(3, A(a + b))
K().foo(3, A(a + b))
}
abstract class K0 {
abstract fun foo(c: Int, a1: A?): Int
}
open class K: K0() {
override fun foo(c: Int, a1: A?) = a + b + c
}
@@ -0,0 +1,26 @@
// APPLY_TO_SUPER
class A {
int x;
A(int x) {
this.x = x;
}
}
interface T {
int foo(int a, int b, int c);
}
class J extends K implements T {
@Override
public int foo(int a, int b, int c) {
return <selection>new A(a + b)</selection>.x * c;
}
}
class Test {
void test() {
new J().foo(1, 2, 3);
new K().foo(1, 2, 3);
}
}
@@ -0,0 +1,26 @@
// APPLY_TO_SUPER
class A {
int x;
A(int x) {
this.x = x;
}
}
interface T {
int foo(int a, int b, int c);
}
class J extends K implements T {
@Override
public int foo(int c, A a1) {
return a1.x * c;
}
}
class Test {
void test() {
new J().foo(3, new A(1 + 2));
new K().foo(3, new A(1 + 2));
}
}