Rethink constraints incorporation

Namely, remove incorporation “otherInsideMyConstraint” to eliminate
constraint system redundancy and produce a potentially very large number
 of constructs.
Instead, introduce not so “spreadable” incorporation during variable
fixation (equality constraint with result type into other constraints).
^KT-41644 Fixed
^KT-42195 Fixed
^KT-42920 Fixed
^KT-42791 Fixed
^KT-41741 Fixed
This commit is contained in:
Victor Petukhov
2020-11-19 12:39:57 +03:00
parent 616e40f879
commit 0857b9c9e7
24 changed files with 299 additions and 136 deletions
@@ -240,11 +240,11 @@ fun case_13() {
<!DEBUG_INFO_EXPRESSION_TYPE("dynamic")!>result_4<!>
<!DEBUG_INFO_EXPRESSION_TYPE("dynamic")!>result_5<!>
<!DEBUG_INFO_EXPRESSION_TYPE("dynamic")!>result_6<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_7<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_8<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_9<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_10<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_11<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(kotlin.collections.MutableList<(kotlin.Int..kotlin.Int?)>..kotlin.collections.List<(kotlin.Int..kotlin.Int?)>?)>")!>result_7<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(kotlin.collections.MutableList<(kotlin.Int..kotlin.Int?)>..kotlin.collections.List<(kotlin.Int..kotlin.Int?)>?)>")!>result_8<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<(kotlin.collections.MutableList<(kotlin.Int..kotlin.Int?)>..kotlin.collections.List<(kotlin.Int..kotlin.Int?)>?)>")!>result_9<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<kotlin.collections.MutableList<kotlin.Int>>")!>result_10<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<kotlin.collections.List<kotlin.Int>?>")!>result_11<!>
<!DEBUG_INFO_EXPRESSION_TYPE("A<dynamic>")!>result_12<!>
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -CAST_NEVER_SUCCEEDS
interface I
interface Inv<P>
interface Out<out T>
class Bar<U : I>(val x: Inv<Out<U>>)
fun <T> materializeFoo(): Inv<T> = null as Inv<T>
fun main() {
Bar(materializeFoo())
}
@@ -0,0 +1,14 @@
// !DIAGNOSTICS: -CAST_NEVER_SUCCEEDS
interface I
interface Inv<P>
interface Out<out T>
class Bar<U : I>(val x: Inv<Out<U>>)
fun <T> materializeFoo(): Inv<T> = null as Inv<T>
fun main() {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Bar<!>(<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materializeFoo<!>())
}
@@ -0,0 +1,30 @@
package
public fun main(): kotlin.Unit
public fun </*0*/ T> materializeFoo(): Inv<T>
public final class Bar</*0*/ U : I> {
public constructor Bar</*0*/ U : I>(/*0*/ x: Inv<Out<U>>)
public final val x: Inv<Out<U>>
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 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 interface Inv</*0*/ P> {
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 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
}