[NI] Revise variance calculation method for completion mode
Before fix only one level of type arguments was used to determine variance of type variable to find out direction requirements. This incorrect in general case, because outer variance affects subtyping deductions, for example: Inv<Out<A>> <: Inv<Out<B>> => A <: B; B <: A, despite A and B are in covariant position if only one level is considered ^KT-36233 Fixed
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T : Derived?> test(derived: T) {
|
||||
id<Out<Base>>(
|
||||
makeOut(
|
||||
makeDnn(derived)
|
||||
)
|
||||
)
|
||||
id<In<Base>>(
|
||||
makeIn(
|
||||
makeDnn(derived)
|
||||
)
|
||||
)
|
||||
id<Inv<Base>>(
|
||||
makeInv(
|
||||
makeDnn(derived)
|
||||
)
|
||||
)
|
||||
id<In<In<Base>>>(
|
||||
makeInIn(
|
||||
makeDnn(derived)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
interface Base
|
||||
open class Derived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
fun <T : Any> makeDnn(arg: T?): T = TODO()
|
||||
fun <T> makeInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> makeOut(arg: T): Out<T> = TODO()
|
||||
fun <T> makeIn(arg: T): In<T> = TODO()
|
||||
fun <T> makeInIn(arg: T): In<In<T>> = TODO()
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun <T : Derived?> test(derived: T) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Base>")!>id<Out<Base>>(
|
||||
makeOut(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>id<In<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>makeIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>id<Inv<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>makeInv(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Base>>")!>id<In<In<Base>>>(
|
||||
makeInIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("T!!")!>makeDnn(derived)<!>
|
||||
)
|
||||
)<!>
|
||||
}
|
||||
|
||||
interface Base
|
||||
open class Derived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
fun <T : Any> makeDnn(arg: T?): T = TODO()
|
||||
fun <T> makeInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> makeOut(arg: T): Out<T> = TODO()
|
||||
fun <T> makeIn(arg: T): In<T> = TODO()
|
||||
fun <T> makeInIn(arg: T): In<In<T>> = TODO()
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||
public fun </*0*/ T : kotlin.Any> makeDnn(/*0*/ arg: T?): T
|
||||
public fun </*0*/ T> makeIn(/*0*/ arg: T): In<T>
|
||||
public fun </*0*/ T> makeInIn(/*0*/ arg: T): In<In<T>>
|
||||
public fun </*0*/ T> makeInv(/*0*/ arg: T): Inv<T>
|
||||
public fun </*0*/ T> makeOut(/*0*/ arg: T): Out<T>
|
||||
public fun </*0*/ T : Derived?> test(/*0*/ derived: T): kotlin.Unit
|
||||
|
||||
public 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 open class Derived : Base {
|
||||
public constructor 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 final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>()
|
||||
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 final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: Test.kt
|
||||
|
||||
fun test(arg: Derived) {
|
||||
id<Out<Base>>(
|
||||
createOut(
|
||||
JavaCls.makeFlexible(arg)
|
||||
)
|
||||
)
|
||||
id<In<Base>>(
|
||||
createIn(
|
||||
JavaCls.makeFlexible(arg)
|
||||
)
|
||||
)
|
||||
id<Inv<Base>>(
|
||||
createInv(
|
||||
JavaCls.makeFlexible(arg)
|
||||
)
|
||||
)
|
||||
id<JavaInv<Out<Base>>>(
|
||||
createJavaInv(
|
||||
JavaCls.makeFlexible(arg)
|
||||
)
|
||||
)
|
||||
id<In<In<Base>>>(
|
||||
createInIn(
|
||||
JavaCls.makeFlexible(arg)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
interface Base
|
||||
class Derived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
|
||||
fun <T> createInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> createOut(arg: T): Out<T> = TODO()
|
||||
fun <T> createIn(arg: T): In<T> = TODO()
|
||||
fun <T> createInIn(arg: T): In<In<T>> = TODO()
|
||||
fun <T> createJavaInv(arg: T): JavaInv<Out<T>> = TODO()
|
||||
|
||||
// FILE: JavaCls.java
|
||||
|
||||
public class JavaCls {
|
||||
public static <T> T makeFlexible(T argument) {
|
||||
return argument;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: JavaInv.java
|
||||
|
||||
public class JavaInv <T> {
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: Test.kt
|
||||
|
||||
fun test(arg: Derived) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Base>")!>id<Out<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<(Derived..Derived?)>")!>createOut(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(Derived..Derived?)")!>JavaCls.makeFlexible(arg)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>id<In<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<(Base..Base?)>")!>createIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(Derived..Derived?)")!>JavaCls.makeFlexible(arg)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>id<Inv<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>createInv(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(Derived..Derived?)")!>JavaCls.makeFlexible(arg)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("JavaInv<Out<Base>>")!>id<JavaInv<Out<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("JavaInv<Out<Base>>")!>createJavaInv(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(Derived..Derived?)")!>JavaCls.makeFlexible(arg)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Base>>")!>id<In<In<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<(Derived..Derived?)>>")!>createInIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(Derived..Derived?)")!>JavaCls.makeFlexible(arg)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
}
|
||||
|
||||
interface Base
|
||||
class Derived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
|
||||
fun <T> createInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> createOut(arg: T): Out<T> = TODO()
|
||||
fun <T> createIn(arg: T): In<T> = TODO()
|
||||
fun <T> createInIn(arg: T): In<In<T>> = TODO()
|
||||
fun <T> createJavaInv(arg: T): JavaInv<Out<T>> = TODO()
|
||||
|
||||
// FILE: JavaCls.java
|
||||
|
||||
public class JavaCls {
|
||||
public static <T> T makeFlexible(T argument) {
|
||||
return argument;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: JavaInv.java
|
||||
|
||||
public class JavaInv <T> {
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> createIn(/*0*/ arg: T): In<T>
|
||||
public fun </*0*/ T> createInIn(/*0*/ arg: T): In<In<T>>
|
||||
public fun </*0*/ T> createInv(/*0*/ arg: T): Inv<T>
|
||||
public fun </*0*/ T> createJavaInv(/*0*/ arg: T): JavaInv<Out<T>>
|
||||
public fun </*0*/ T> createOut(/*0*/ arg: T): Out<T>
|
||||
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||
public fun test(/*0*/ arg: Derived): kotlin.Unit
|
||||
|
||||
public 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 final class Derived : Base {
|
||||
public constructor 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 final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>()
|
||||
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 final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public open class JavaCls {
|
||||
public constructor JavaCls()
|
||||
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 open fun </*0*/ T : kotlin.Any!> makeFlexible(/*0*/ argument: T!): T!
|
||||
}
|
||||
|
||||
public open class JavaInv</*0*/ T : kotlin.Any!> {
|
||||
public constructor JavaInv</*0*/ T : kotlin.Any!>()
|
||||
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 final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>()
|
||||
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
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(a: D1, b: D2) {
|
||||
id<Out<Base>>(
|
||||
makeOut(
|
||||
select(a, b)
|
||||
)
|
||||
)
|
||||
id<Inv<Base>>(
|
||||
makeInv(
|
||||
select(a, b)
|
||||
)
|
||||
)
|
||||
id<In<Base>>(
|
||||
makeIn(
|
||||
select(a, b)
|
||||
)
|
||||
)
|
||||
id<In<In<Base>>>(
|
||||
makeInIn(
|
||||
select(a, b)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
interface Base
|
||||
interface B1 : Base
|
||||
interface B2 : Base
|
||||
interface D1 : B1, B2
|
||||
interface D2 : B1, B2
|
||||
|
||||
fun <S> select(a: S, b: S): S = TODO()
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
fun <T> makeInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> makeOut(arg: T): Out<T> = TODO()
|
||||
fun <T> makeIn(arg: T): In<T> = TODO()
|
||||
fun <T> makeInIn(arg: T): In<In<T>> = TODO()
|
||||
@@ -0,0 +1,42 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(a: D1, b: D2) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Base>")!>id<Out<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<{B1 & B2}>")!>makeOut(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{B1 & B2}")!>select(a, b)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>id<Inv<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Base>")!>makeInv(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{B1 & B2}")!>select(a, b)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>id<In<Base>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Base>")!>makeIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{B1 & B2}")!>select(a, b)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Base>>")!>id<In<In<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<{B1 & B2}>>")!>makeInIn(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("{B1 & B2}")!>select(a, b)<!>
|
||||
)<!>
|
||||
)<!>
|
||||
}
|
||||
|
||||
interface Base
|
||||
interface B1 : Base
|
||||
interface B2 : Base
|
||||
interface D1 : B1, B2
|
||||
interface D2 : B1, B2
|
||||
|
||||
fun <S> select(a: S, b: S): S = TODO()
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
fun <T> makeInv(arg: T): Inv<T> = TODO()
|
||||
fun <T> makeOut(arg: T): Out<T> = TODO()
|
||||
fun <T> makeIn(arg: T): In<T> = TODO()
|
||||
fun <T> makeInIn(arg: T): In<In<T>> = TODO()
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||
public fun </*0*/ T> makeIn(/*0*/ arg: T): In<T>
|
||||
public fun </*0*/ T> makeInIn(/*0*/ arg: T): In<In<T>>
|
||||
public fun </*0*/ T> makeInv(/*0*/ arg: T): Inv<T>
|
||||
public fun </*0*/ T> makeOut(/*0*/ arg: T): Out<T>
|
||||
public fun </*0*/ S> select(/*0*/ a: S, /*1*/ b: S): S
|
||||
public fun test(/*0*/ a: D1, /*1*/ b: D2): kotlin.Unit
|
||||
|
||||
public interface B1 : 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 interface B2 : 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 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 interface D1 : B1, B2 {
|
||||
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
|
||||
}
|
||||
|
||||
public interface D2 : B1, B2 {
|
||||
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
|
||||
}
|
||||
|
||||
public final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>()
|
||||
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 final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -USELESS_CAST
|
||||
|
||||
class Inv<T>
|
||||
class Out<out T>
|
||||
|
||||
fun <K> foo(y: K?) = Inv<Out<K>>()
|
||||
fun <R> test(x: Inv<Out<R>>) {}
|
||||
|
||||
fun main() {
|
||||
test<Int>(foo(null)) // type mismatch
|
||||
test<Number>(foo(1 as Int)) // type mismatch
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -USELESS_CAST
|
||||
|
||||
class Inv<T>
|
||||
class Out<out T>
|
||||
|
||||
fun <K> foo(y: K?) = Inv<Out<K>>()
|
||||
fun <R> test(x: Inv<Out<R>>) {}
|
||||
|
||||
fun main() {
|
||||
test<Int>(foo(null)) // type mismatch
|
||||
test<Number>(foo(1 as Int)) // type mismatch
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> foo(/*0*/ y: K?): Inv<Out<K>>
|
||||
public fun main(): kotlin.Unit
|
||||
public fun </*0*/ R> test(/*0*/ x: Inv<Out<R>>): kotlin.Unit
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out T> {
|
||||
public constructor Out</*0*/ out 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
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Base
|
||||
class Derived : Base
|
||||
class OtherDerived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
class BiParam<out F, out S>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
|
||||
fun <D> createDoubleIn(arg: D): In<In<D>> = TODO()
|
||||
fun <D> createDoubleInOut1(arg: D): In<In<Out<D>>> = TODO()
|
||||
fun <D> createDoubleInOut2(arg: D): In<Out<In<D>>> = TODO()
|
||||
fun <D> createDoubleInOut3(arg: D): Out<In<In<D>>> = TODO()
|
||||
|
||||
fun <D> createInOut(arg: D): In<Out<D>> = TODO()
|
||||
fun <D> createOutIn(arg: D): Out<In<D>> = TODO()
|
||||
fun <D> createInvOut(arg: D): Inv<Out<D>> = TODO()
|
||||
fun <D> createOutInvDoubleIn(arg: D): Out<Inv<In<In<D>>>> = TODO()
|
||||
|
||||
fun <F, S> biparamEarly(first: F, second: S): BiParam<In<In<F>>, Out<S>> = TODO()
|
||||
fun <F, S> biparamEarlyIrrelevantInv(first: F, second: S): BiParam<In<In<F>>, Inv<String>> = TODO()
|
||||
fun <F, S> biparamEarlyStarProjection(first: F, second: S): BiParam<*, In<In<S>>> = TODO()
|
||||
|
||||
fun <F, S> biparamLateIn(first: F, second: S): BiParam<In<Out<F>>, S> = TODO()
|
||||
fun <F, S> biparamLateInv(first: F, second: S): BiParam<Inv<Out<F>>, S> = TODO()
|
||||
|
||||
fun <T> take(biParam: BiParam<*, In<In<T>>>) {}
|
||||
|
||||
fun testEarlyCompletion(derived: Derived, otherDerived: OtherDerived) {
|
||||
id<In<In<Base>>>(
|
||||
createDoubleIn(derived)
|
||||
)
|
||||
id<In<In<Out<Base>>>>(
|
||||
createDoubleInOut1(derived)
|
||||
)
|
||||
id<In<Out<In<Base>>>>(
|
||||
createDoubleInOut2(derived)
|
||||
)
|
||||
id<Out<In<In<Base>>>>(
|
||||
createDoubleInOut3(derived)
|
||||
)
|
||||
id<BiParam<In<In<Base>>, Out<Base>>>(
|
||||
biparamEarly(derived, otherDerived)
|
||||
)
|
||||
id<BiParam<In<In<Base>>, Inv<String>>>(
|
||||
biparamEarlyIrrelevantInv(derived, otherDerived)
|
||||
)
|
||||
take<Base>(
|
||||
biparamEarlyStarProjection(derived, otherDerived)
|
||||
)
|
||||
}
|
||||
|
||||
fun testLateCompletion(derived: Derived, otherDerived: OtherDerived) {
|
||||
id<In<Out<Base>>>(
|
||||
createInOut(derived)
|
||||
)
|
||||
id<Out<In<Base>>>(
|
||||
createOutIn(derived)
|
||||
)
|
||||
id<Inv<Out<Base>>>(
|
||||
createInvOut(derived)
|
||||
)
|
||||
id<Out<Inv<In<In<Base>>>>>(
|
||||
createOutInvDoubleIn(derived)
|
||||
)
|
||||
id<BiParam<In<Out<Base>>, OtherDerived>>(
|
||||
biparamLateIn(derived, otherDerived)
|
||||
)
|
||||
id<BiParam<Inv<Out<Base>>, OtherDerived>>(
|
||||
biparamLateInv(derived, otherDerived)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface Base
|
||||
class Derived : Base
|
||||
class OtherDerived : Base
|
||||
|
||||
class Inv<T>
|
||||
class Out<out O>
|
||||
class In<in I>
|
||||
|
||||
class BiParam<out F, out S>
|
||||
|
||||
fun <K> id(arg: K) = arg
|
||||
|
||||
fun <D> createDoubleIn(arg: D): In<In<D>> = TODO()
|
||||
fun <D> createDoubleInOut1(arg: D): In<In<Out<D>>> = TODO()
|
||||
fun <D> createDoubleInOut2(arg: D): In<Out<In<D>>> = TODO()
|
||||
fun <D> createDoubleInOut3(arg: D): Out<In<In<D>>> = TODO()
|
||||
|
||||
fun <D> createInOut(arg: D): In<Out<D>> = TODO()
|
||||
fun <D> createOutIn(arg: D): Out<In<D>> = TODO()
|
||||
fun <D> createInvOut(arg: D): Inv<Out<D>> = TODO()
|
||||
fun <D> createOutInvDoubleIn(arg: D): Out<Inv<In<In<D>>>> = TODO()
|
||||
|
||||
fun <F, S> biparamEarly(first: F, second: S): BiParam<In<In<F>>, Out<S>> = TODO()
|
||||
fun <F, S> biparamEarlyIrrelevantInv(first: F, second: S): BiParam<In<In<F>>, Inv<String>> = TODO()
|
||||
fun <F, S> biparamEarlyStarProjection(first: F, second: S): BiParam<*, In<In<S>>> = TODO()
|
||||
|
||||
fun <F, S> biparamLateIn(first: F, second: S): BiParam<In<Out<F>>, S> = TODO()
|
||||
fun <F, S> biparamLateInv(first: F, second: S): BiParam<Inv<Out<F>>, S> = TODO()
|
||||
|
||||
fun <T> take(biParam: BiParam<*, In<In<T>>>) {}
|
||||
|
||||
fun testEarlyCompletion(derived: Derived, otherDerived: OtherDerived) {
|
||||
id<In<In<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Derived>>")!>createDoubleIn(derived)<!>
|
||||
)
|
||||
id<In<In<Out<Base>>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<In<Out<Derived>>>")!>createDoubleInOut1(derived)<!>
|
||||
)
|
||||
id<In<Out<In<Base>>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Out<In<Derived>>>")!>createDoubleInOut2(derived)<!>
|
||||
)
|
||||
id<Out<In<In<Base>>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<In<In<Derived>>>")!>createDoubleInOut3(derived)<!>
|
||||
)
|
||||
id<BiParam<In<In<Base>>, Out<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<In<In<Derived>>, Out<OtherDerived>>")!>biparamEarly(derived, otherDerived)<!>
|
||||
)
|
||||
id<BiParam<In<In<Base>>, Inv<String>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<In<In<Derived>>, Inv<kotlin.String>>")!>biparamEarlyIrrelevantInv(derived, otherDerived)<!>
|
||||
)
|
||||
take<Base>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<*, In<In<OtherDerived>>>")!>biparamEarlyStarProjection(derived, otherDerived)<!>
|
||||
)
|
||||
}
|
||||
|
||||
fun testLateCompletion(derived: Derived, otherDerived: OtherDerived) {
|
||||
id<In<Out<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("In<Out<Base>>")!>createInOut(derived)<!>
|
||||
)
|
||||
id<Out<In<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<In<Base>>")!>createOutIn(derived)<!>
|
||||
)
|
||||
id<Inv<Out<Base>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<Out<Base>>")!>createInvOut(derived)<!>
|
||||
)
|
||||
id<Out<Inv<In<In<Base>>>>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Out<Inv<In<In<Base>>>>")!>createOutInvDoubleIn(derived)<!>
|
||||
)
|
||||
id<BiParam<In<Out<Base>>, OtherDerived>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<In<Out<Base>>, OtherDerived>")!>biparamLateIn(derived, otherDerived)<!>
|
||||
)
|
||||
id<BiParam<Inv<Out<Base>>, OtherDerived>>(
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("BiParam<Inv<Out<Base>>, OtherDerived>")!>biparamLateInv(derived, otherDerived)<!>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ F, /*1*/ S> biparamEarly(/*0*/ first: F, /*1*/ second: S): BiParam<In<In<F>>, Out<S>>
|
||||
public fun </*0*/ F, /*1*/ S> biparamEarlyIrrelevantInv(/*0*/ first: F, /*1*/ second: S): BiParam<In<In<F>>, Inv<kotlin.String>>
|
||||
public fun </*0*/ F, /*1*/ S> biparamEarlyStarProjection(/*0*/ first: F, /*1*/ second: S): BiParam<*, In<In<S>>>
|
||||
public fun </*0*/ F, /*1*/ S> biparamLateIn(/*0*/ first: F, /*1*/ second: S): BiParam<In<Out<F>>, S>
|
||||
public fun </*0*/ F, /*1*/ S> biparamLateInv(/*0*/ first: F, /*1*/ second: S): BiParam<Inv<Out<F>>, S>
|
||||
public fun </*0*/ D> createDoubleIn(/*0*/ arg: D): In<In<D>>
|
||||
public fun </*0*/ D> createDoubleInOut1(/*0*/ arg: D): In<In<Out<D>>>
|
||||
public fun </*0*/ D> createDoubleInOut2(/*0*/ arg: D): In<Out<In<D>>>
|
||||
public fun </*0*/ D> createDoubleInOut3(/*0*/ arg: D): Out<In<In<D>>>
|
||||
public fun </*0*/ D> createInOut(/*0*/ arg: D): In<Out<D>>
|
||||
public fun </*0*/ D> createInvOut(/*0*/ arg: D): Inv<Out<D>>
|
||||
public fun </*0*/ D> createOutIn(/*0*/ arg: D): Out<In<D>>
|
||||
public fun </*0*/ D> createOutInvDoubleIn(/*0*/ arg: D): Out<Inv<In<In<D>>>>
|
||||
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||
public fun </*0*/ T> take(/*0*/ biParam: BiParam<*, In<In<T>>>): kotlin.Unit
|
||||
public fun testEarlyCompletion(/*0*/ derived: Derived, /*1*/ otherDerived: OtherDerived): kotlin.Unit
|
||||
public fun testLateCompletion(/*0*/ derived: Derived, /*1*/ otherDerived: OtherDerived): kotlin.Unit
|
||||
|
||||
public 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 final class BiParam</*0*/ out F, /*1*/ out S> {
|
||||
public constructor BiParam</*0*/ out F, /*1*/ out S>()
|
||||
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 final class Derived : Base {
|
||||
public constructor 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 final class In</*0*/ in I> {
|
||||
public constructor In</*0*/ in I>()
|
||||
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 final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public final class OtherDerived : Base {
|
||||
public constructor OtherDerived()
|
||||
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 final class Out</*0*/ out O> {
|
||||
public constructor Out</*0*/ out O>()
|
||||
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
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
|
||||
|
||||
class Inv<T>
|
||||
class Out<out T>
|
||||
|
||||
fun <K> invOut(y: K?): Inv<Out<K>> = TODO()
|
||||
fun <R> test(x: Inv<Out<R>>): R = TODO()
|
||||
|
||||
fun testNothing() {
|
||||
test(invOut(null)) checkType { <!UNRESOLVED_REFERENCE!>_<!><Nothing>() }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE
|
||||
|
||||
class Inv<T>
|
||||
class Out<out T>
|
||||
|
||||
fun <K> invOut(y: K?): Inv<Out<K>> = TODO()
|
||||
fun <R> test(x: Inv<Out<R>>): R = TODO()
|
||||
|
||||
fun testNothing() {
|
||||
<!IMPLICIT_NOTHING_AS_TYPE_PARAMETER!>test<!>(invOut(null)) checkType { _<Nothing>() }
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> invOut(/*0*/ y: K?): Inv<Out<K>>
|
||||
public fun </*0*/ R> test(/*0*/ x: Inv<Out<R>>): R
|
||||
public fun testNothing(): kotlin.Unit
|
||||
|
||||
public final class Inv</*0*/ T> {
|
||||
public constructor Inv</*0*/ 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
|
||||
}
|
||||
|
||||
public final class Out</*0*/ out T> {
|
||||
public constructor Out</*0*/ out 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
|
||||
}
|
||||
Reference in New Issue
Block a user