Fix primitive override problem in Kotlin-Java inheritance

See the comment in JetTypeMapper
This commit is contained in:
Alexander Udalov
2013-12-25 19:39:57 +04:00
parent 2ea62bde23
commit 713c6f13ae
26 changed files with 358 additions and 2 deletions
@@ -0,0 +1,18 @@
class ExtendsB extends B {
void test() {
byte x = foo();
Byte y = foo();
Object z = foo();
}
}
class ExtendsC extends C {
void test() {
byte x = foo();
Byte y = foo();
Object z = foo();
}
@Override
public Byte foo() { return 42; }
}
@@ -0,0 +1,9 @@
trait A<T> {
fun foo(): T
}
open class B : A<Byte> {
override fun foo(): Byte = 42
}
abstract class C : A<Byte>
@@ -0,0 +1,13 @@
class Test {
void test() {
A<Integer> a = new B();
int ax = a.foo();
Integer ay = a.foo();
Object az = a.foo();
B b = new B();
int bx = b.foo();
Integer by = b.foo();
Object bz = b.foo();
}
}
@@ -0,0 +1,7 @@
trait A<T> {
fun foo(): T
}
class B : A<Int> {
override final fun foo(): Int = 42
}
@@ -0,0 +1,13 @@
class Test {
void test() {
A<Integer> a = new B();
int ax = a.foo();
Integer ay = a.foo();
Object az = a.foo();
B b = new B();
int bx = b.foo();
Integer by = b.foo();
Object bz = b.foo();
}
}
@@ -0,0 +1,7 @@
trait A<T> {
fun foo(): T
}
class B : A<Int> {
override fun foo(): Int = 42
}
@@ -0,0 +1,7 @@
class Test extends B {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
@@ -0,0 +1,7 @@
trait A {
fun foo(): Any
}
open class B : A {
override fun foo(): Int = 42
}
@@ -0,0 +1,13 @@
class Test extends B {
void test() {
A<Integer> a = new B();
int ax = a.foo();
Integer ay = a.foo();
Object az = a.foo();
B b = new B();
int bx = b.foo();
Integer by = b.foo();
Object bz = b.foo();
}
}
@@ -0,0 +1,7 @@
trait A<T> {
fun foo(): T
}
open class B : A<Int> {
override final fun foo(): Int = 42
}
@@ -0,0 +1,18 @@
class ExtendsB extends B {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
class ExtendsC extends C {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
@Override
public Integer foo() { return 42; }
}
@@ -0,0 +1,9 @@
trait A<T : Comparable<T>> {
fun foo(): T
}
open class B : A<Int> {
override fun foo(): Int = 42
}
abstract class C : A<Int>
@@ -0,0 +1,18 @@
class ExtendsB extends B {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
class ExtendsC extends C {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
@Override
public Integer foo() { return 42; }
}
@@ -0,0 +1,9 @@
trait A<T : Number> {
fun foo(): T
}
open class B : A<Int> {
override fun foo(): Int = 42
}
abstract class C : A<Int>
@@ -0,0 +1,18 @@
class ExtendsB extends B {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
class ExtendsC extends C {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
@Override
public Integer foo() { return 42; }
}
@@ -0,0 +1,9 @@
trait A<T> {
fun foo(): T
}
open class B : A<Int> {
override fun foo(): Int = 42
}
abstract class C : A<Int>
@@ -0,0 +1,7 @@
class ExtendsD extends D {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
@@ -0,0 +1,11 @@
trait A<T> {
fun foo(): T
}
trait B : A
abstract class C : B
open class D : C() {
override fun foo(): Int = 42
}
@@ -0,0 +1,18 @@
class ExtendsB extends B {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
class ExtendsC extends C {
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
@Override
public Integer foo() { return 42; }
}
@@ -0,0 +1,9 @@
trait A<T> {
fun foo(): T
}
open class B : A<Int?> {
override fun foo(): Int? = 42
}
abstract class C : A<Int?>
@@ -0,0 +1,12 @@
class ExtendsB extends B {
@Override
public Integer foo() {
return 239;
}
void test() {
int x = foo();
Integer y = foo();
Object z = foo();
}
}
@@ -0,0 +1,7 @@
trait A<T> {
fun foo(): T
}
abstract class B : A<Int> {
override abstract fun foo(): Int
}