Introduce Parameter: Java -> Kotlin Interoperability
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
+12
@@ -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
|
||||
}
|
||||
+12
@@ -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
|
||||
}
|
||||
+26
@@ -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);
|
||||
}
|
||||
}
|
||||
+26
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user