Type<*> is inferred now if Type<A> and Type<B> common supertype is Type<X> and X is not within parameter upper bound. #KT-7585 Fixed. #EA-68943 Fixed.

It provides also a fix for KT-7585 (empty type intersection assertion).
A set of relevant tests, one fixed test
This commit is contained in:
Mikhail Glukhikh
2015-04-27 11:27:57 +03:00
parent c90bcb41f3
commit 754f8af3fc
12 changed files with 418 additions and 2 deletions
@@ -0,0 +1,73 @@
// FILE: Base.java
interface Base {}
// FILE: Other.java
interface Other {}
// FILE: Derived.java
final class Derived<T> implements Base, Other {}
// FILE: Exotic.java
final class Exotic implements Base, Other {
int x;
Exotic(int x) {
this.x = x;
}
}
// FILE: Properties.java
import kotlin.jvm.functions.Function0;
class Val<T> {
Function0<T> initializer;
Val(Function0<T> initializer) {
this.initializer = initializer;
}
T get(Object instance, Object metadata) {
return initializer.invoke();
}
}
class Properties {
static <T> Val<T> calcVal(Function0<T> initializer) {
return new Val<T>(initializer);
}
}
// FILE: My.kt
open class Wrapper<out T: Base>(val v: T)
class DerivedWrapper(v: Derived<*>): Wrapper<Derived<*>>(v)
class ExoticWrapper(v: Exotic): Wrapper<Exotic>(v)
object MyBase {
fun derived() = Derived<String>()
fun exotic(x: Int) = Exotic(x)
fun derivedWrapper() = DerivedWrapper(derived())
fun exoticWrapper(x: Int) = ExoticWrapper(exotic(x))
}
class My(val x: Int) {
val wrapper/*: Wrapper<*>*/ by Properties.calcVal {
val y = x + 1
when {
y > 0 -> MyBase.derivedWrapper()
x < 0 -> MyBase.exoticWrapper(x)
else -> throw java.lang.NullPointerException("")
}
}
}
@@ -0,0 +1,82 @@
package
public/*package*/ interface Base {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public/*package*/ final class Derived</*0*/ T : kotlin.Any!> : Base, Other {
public/*package*/ constructor Derived</*0*/ T : kotlin.Any!>()
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class DerivedWrapper : Wrapper<Derived<*>> {
public constructor DerivedWrapper(/*0*/ v: Derived<*>)
internal final override /*1*/ /*fake_override*/ val v: Derived<*>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public/*package*/ final class Exotic : Base, Other {
public/*package*/ constructor Exotic(/*0*/ x: kotlin.Int)
public/*package*/ final var x: kotlin.Int
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class ExoticWrapper : Wrapper<Exotic> {
public constructor ExoticWrapper(/*0*/ v: Exotic)
internal final override /*1*/ /*fake_override*/ val v: Exotic
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class My {
public constructor My(/*0*/ x: kotlin.Int)
internal final val wrapper: Wrapper<*>!
internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal object MyBase {
private constructor MyBase()
internal final fun derived(): Derived<kotlin.String>
internal final fun derivedWrapper(): DerivedWrapper
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final fun exotic(/*0*/ x: kotlin.Int): Exotic
internal final fun exoticWrapper(/*0*/ x: kotlin.Int): ExoticWrapper
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public/*package*/ interface Other {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public/*package*/ open class Properties {
public/*package*/ constructor Properties()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public/*package*/ open fun </*0*/ T : kotlin.Any!> calcVal(/*0*/ initializer: (() -> T!)!): Val<T!>!
}
internal open class Wrapper</*0*/ out T : Base> {
public constructor Wrapper</*0*/ out T : Base>(/*0*/ v: T)
internal final val v: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}