Change Signature: Add support of type parameter substitutions in overriding members

This commit is contained in:
Alexey Sedunov
2014-12-02 14:02:15 +03:00
parent 250940c824
commit c917459926
29 changed files with 638 additions and 131 deletions
@@ -0,0 +1,34 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
interface J<A, B> extends T<A, B> {
@Nullable
@Override
<C> U<C> foofoofoo(@NotNull List<? extends C> a, @Nullable A b, @NotNull U<B> c);
}
abstract class J1<X, Y> implements J<U<X>, U<Y>> {
@Nullable
@Override
public <C> U<C> foofoofoo(@NotNull List<? extends C> xu, @Nullable U<X> yu, @NotNull U<U<Y>> c) {
throw new UnsupportedOperationException();
}
}
abstract class J2<X> extends J1<X, String> {
@Nullable
@Override
public <C> U<C> foofoofoo(@NotNull List<? extends C> xu, @Nullable U<X> stringU, @NotNull U<U<String>> c) {
throw new UnsupportedOperationException();
}
}
class J3 extends J2<Object> {
@Nullable
@Override
public <D> U<D> foofoofoo(@NotNull List<? extends D> objectU, @Nullable U<Object> stringU, @NotNull U<U<String>> c) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,23 @@
class U<A>
trait T<A, B> {
fun foofoofoo<C>(a: List<C>, b: A?, c: U<B>): U<C>?
}
abstract class T1<X, Y> : T<U<X>, U<Y>> {
override fun <C> foofoofoo(a: List<C>, b: U<X>?, c: U<U<Y>>): U<C>? {
throw UnsupportedOperationException()
}
}
abstract class T2<X> : T1<X, String>() {
override fun <C> foofoofoo(a: List<C>, b: U<X>?, c: U<U<String>>): U<C>? {
throw UnsupportedOperationException()
}
}
class T3 : T2<Any>() {
override fun foofoofoo<D>(a: List<D>, b: U<Any>?, c: U<U<String>>): U<D>? {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,25 @@
interface J<A, B> extends T<A, B> {
@Override
<C> int foofoofoo(A a, B b, C c);
}
abstract class J1<X, Y> implements J<U<X>, U<Y>> {
@Override
public <C> int foofoofoo(U<X> xu, U<Y> yu, C c) {
throw new UnsupportedOperationException();
}
}
abstract class J2<X> extends J1<X, String> {
@Override
public <C> int foofoofoo(U<X> xu, U<String> stringU, C c) {
throw new UnsupportedOperationException();
}
}
class J3 extends J2<Object> {
@Override
public <D> int foofoofoo(U<Object> objectU, U<String> stringU, D c) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,23 @@
class U<A>
trait T<A, B> {
fun <caret>foofoofoo<C>(a: A, b: B, c: C): Int
}
abstract class T1<X, Y> : T<U<X>, U<Y>> {
override fun <C> foofoofoo(a: U<X>, b: U<Y>, c: C): Int {
throw UnsupportedOperationException()
}
}
abstract class T2<X> : T1<X, String>() {
override fun <C> foofoofoo(a: U<X>, b: U<String>, c: C): Int {
throw UnsupportedOperationException()
}
}
class T3 : T2<Any>() {
override fun foofoofoo<D>(a: U<Any>, b: U<String>, c: D): Int {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,5 @@
fun test() {
SamTest.test(Foo<String, Int> { (s, n) -> "" })
SamTest.test(Foo { (s: MutableList<X<Int>>, n: X<MutableSet<String>>) -> "" })
SamTest.test(Foo { (s: MutableList<X<Int>>, n: X<MutableSet<String>>): X<MutableList<String>>? -> "" })
}
@@ -0,0 +1,16 @@
import java.util.List;
import java.util.Set;
class X<A> {
}
interface Foo<A, B> {
X<List<A>> foo(List<X<B>> a, X<Set<A>> b);
}
class SamTest {
static <A, B> void test(Foo<A, B> foo) {
}
}
@@ -0,0 +1,5 @@
fun test() {
SamTest.test(Foo<String, Int> { (s, n) -> "" })
SamTest.test(Foo { (s: String, n: Int) -> "" })
SamTest.test(Foo { (s: String, n: Int): String -> "" })
}
@@ -0,0 +1,13 @@
class X<A> {
}
interface Foo<A, B> {
A <caret>foo(A a, B b);
}
class SamTest {
static <A, B> void test(Foo<A, B> foo) {
}
}
@@ -1,4 +1,4 @@
fun test() {
JTest.samTest(SAM { (s, n) -> s + " " })
JTest.samTest(SAM { (s: Any?, n: Int) -> x + " " })
JTest.samTest(SAM { (s: Any, n: Int) -> x + " " })
}