Change "most specific return type" definition for fake overrides.

Given overridden descriptors D = d[i].
1. Find D*, subset of D:
  returnType(d* from D*) <: returnType(d) for each d from D.
  Always prefer var to val.
2. Prefer non-flexible return type to flexible.

Check for var/val overrides properly
(NB: this will report PROPERTY_TYPE_MISMATCH_ON_OVERRIDE
for all properties, not just overrides involving vars as it was before).
This commit is contained in:
Dmitry Petrov
2015-12-07 17:16:14 +03:00
parent 594039ac42
commit 94bea54db3
12 changed files with 312 additions and 48 deletions
@@ -0,0 +1,56 @@
// FILE: JFooWithUpperBound.java
public interface JFooWithUpperBound<T extends IBase> {
T foo();
}
// FILE: JFooWithUpperBoundDerived.java
public interface JFooWithUpperBoundDerived<T extends IBase> extends JFooWithUpperBound<T> {
}
// FILE: JCFooWithUpperBound.java
public class JCFooWithUpperBound<T extends IBase> {
public T foo() {
return null;
}
}
// FILE: JCFooWithUpperBoundDerived.java
public class JCFooWithUpperBoundDerived<T extends IBase> extends JCFooWithUpperBound<T> {
}
// FILE: K.kt
interface IBase
interface IDerived : IBase
interface IFooWithUpperBound<T : IBase> {
fun foo(): T
}
interface IFooT<T> {
fun foo(): T
}
interface IFoo {
fun foo(): IBase
}
interface IFooDerived : IFoo {
override fun foo(): IDerived
}
interface IFooWithUpperBoundDerived<T : IBase> : IFooWithUpperBound<T>
interface Test1<T : IBase> : IFooWithUpperBound<T>, IFoo
interface Test2<T : IBase> : IFooT<T>, IFoo
interface Test3<T : IDerived> : IFooWithUpperBoundDerived<T>, IFooDerived
interface Test4<T : IBase> : JFooWithUpperBound<T>, IFoo
interface Test5<T : IDerived> : JFooWithUpperBoundDerived<T>, IFooDerived
class Test6<T : IBase> : JCFooWithUpperBound<T>(), IFoo
class Test7<T : IDerived> : JCFooWithUpperBoundDerived<T>(), IFooDerived