[FE 1.0] Build captured type's supertypes in an alternative way: use own projection type as a first supertype, then supertypes from the corresponding type parameter's upper bounds

The original case provoked forking a constraint system which isn't supported in K1 (K2 only). If the captured type is recursive, then type parameter's upper bounds may break subtyping due to substitution the current captured type again, into a recursive type parameter.

Note that we already have special logic for recursive captured types. See `isTypeVariableAgainstStarProjectionForSelfType`.

^KT-52782 Fixed
This commit is contained in:
Victor Petukhov
2022-06-17 15:01:53 +02:00
parent 37ccd85e59
commit eb19d39cbf
9 changed files with 83 additions and 14 deletions
@@ -0,0 +1,13 @@
// FIR_IDENTICAL
// FILE: Foo.java
public abstract class Foo<K extends Bar<? extends Foo<K>>> {
abstract String getTest();
}
// FILE: Bar.java
public abstract class Bar<T extends Foo<? extends Bar<T>>> {}
// FILE: main.kt
fun box(foo: Foo<*>) {
foo.test // unresolved in 1.7.0, OK before
}
@@ -0,0 +1,18 @@
package
public fun box(/*0*/ foo: Foo<*>): kotlin.Unit
public abstract class Bar</*0*/ T : Foo<out Bar<T!>!>!> {
public constructor Bar</*0*/ T : Foo<out Bar<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 abstract class Foo</*0*/ K : Bar<out Foo<K!>!>!> {
public constructor Foo</*0*/ K : Bar<out Foo<K!>!>!>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public/*package*/ abstract fun getTest(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
+1 -1
View File
@@ -30,7 +30,7 @@ fun String.asFsdAddress(): String {
fun box(): String {
val state = Test().state
if (state is GoBuildingRunningState<*>) {
state.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>buildingWorkingDirectory<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>asFsdAddress<!>()
<!DEBUG_INFO_SMARTCAST!>state<!>.buildingWorkingDirectory.asFsdAddress()
}
return "OK"
}