[FIR] Unwrap definitely not-null types in type parameter cycle checks
#KT-58944 Fixed
This commit is contained in:
+7
-1
@@ -289,8 +289,14 @@ open class FirTypeResolveTransformer(
|
||||
if (visited.isNotEmpty() && currentTypeParameter == typeParameter) return true
|
||||
if (!visited.add(currentTypeParameter)) return false
|
||||
|
||||
fun ConeKotlinType.toNextTypeParameter(): FirTypeParameter? = when (this) {
|
||||
is ConeTypeParameterType -> lookupTag.typeParameterSymbol.fir
|
||||
is ConeDefinitelyNotNullType -> original.toNextTypeParameter()
|
||||
else -> null
|
||||
}
|
||||
|
||||
return currentTypeParameter.bounds.any {
|
||||
val nextTypeParameter = it.coneTypeSafe<ConeTypeParameterType>()?.lookupTag?.typeParameterSymbol?.fir ?: return@any false
|
||||
val nextTypeParameter = it.coneTypeOrNull?.toNextTypeParameter() ?: return@any false
|
||||
|
||||
hasSupertypePathToParameter(nextTypeParameter, typeParameter, visited)
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,4 +8,5 @@ class A2<K : Comparable<K & Any>?>
|
||||
|
||||
fun <R : T & Any, T> bar() {}
|
||||
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : <!INCORRECT_LEFT_COMPONENT_OF_INTERSECTION!>E<!> & Any<!>> baz() {}
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : E & Any<!>> baz1() {}
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : E & Any<!>> E?.baz2() {}
|
||||
|
||||
Vendored
+2
-1
@@ -8,4 +8,5 @@ class A2<K : Comparable<<!INCORRECT_LEFT_COMPONENT_OF_INTERSECTION!>K<!> & Any>?
|
||||
|
||||
fun <R : T & Any, T> bar() {}
|
||||
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : <!INCORRECT_LEFT_COMPONENT_OF_INTERSECTION!>E & Any<!><!>> baz() {}
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : <!INCORRECT_LEFT_COMPONENT_OF_INTERSECTION!>E & Any<!><!>> baz1() {}
|
||||
fun <<!CYCLIC_GENERIC_UPPER_BOUND!>E : <!INCORRECT_LEFT_COMPONENT_OF_INTERSECTION!>E & Any<!><!>> E?.baz2() {}
|
||||
|
||||
compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/recursiveBounds.txt
Vendored
+2
-1
@@ -1,9 +1,10 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ R : T & Any, /*1*/ T> bar(): kotlin.Unit
|
||||
public fun </*0*/ E : [Error type: Cyclic upper bounds]> baz(): kotlin.Unit
|
||||
public fun </*0*/ E : [Error type: Cyclic upper bounds]> baz1(): kotlin.Unit
|
||||
public fun </*0*/ T : kotlin.Comparable<T & Any>> sort1(): kotlin.Unit
|
||||
public fun </*0*/ T : kotlin.Comparable<T & Any>?> sort2(): kotlin.Unit
|
||||
public fun </*0*/ E : [Error type: Cyclic upper bounds]> [Error type: Error type parameter]?.baz2(): kotlin.Unit
|
||||
|
||||
public final class A1</*0*/ K : kotlin.Comparable<K>> {
|
||||
public constructor A1</*0*/ K : kotlin.Comparable<K>>()
|
||||
|
||||
Reference in New Issue
Block a user