[FIR] Fix stackoverflow when checking for type cast erasure

#KT-59478 Fixed
This commit is contained in:
Brian Norman
2023-08-25 11:29:08 -05:00
committed by Space Team
parent 593b326c80
commit e48ab4deb4
4 changed files with 14 additions and 3 deletions
@@ -128,7 +128,7 @@ fun isCastErased(supertype: ConeKotlinType, subtype: ConeKotlinType, context: Ch
}
// cast between T and T? is always OK
if (supertype.isMarkedNullable || subtype.isMarkedNullable) {
if ((supertype !is ConeErrorType && supertype.isMarkedNullable) || (subtype !is ConeErrorType && subtype.isMarkedNullable)) {
return isCastErased(
supertype.withNullability(ConeNullability.NOT_NULL, typeContext),
subtype.withNullability(ConeNullability.NOT_NULL, typeContext),
@@ -3,4 +3,9 @@ class P
fun foo(p: P): Any {
val v = p as <!UNRESOLVED_REFERENCE!>G<!>
return v
}
}
fun bar(p: P): Any {
val v = p as <!UNRESOLVED_REFERENCE!>G<!>?
return v
}
@@ -3,4 +3,9 @@ class P
fun foo(p: P): Any {
val v = p as <!UNRESOLVED_REFERENCE!>G<!>
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>v<!>
}
}
fun bar(p: P): Any {
val v = p as <!UNRESOLVED_REFERENCE!>G<!>?
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>v<!>
}
@@ -1,5 +1,6 @@
package
public fun bar(/*0*/ p: P): kotlin.Any
public fun foo(/*0*/ p: P): kotlin.Any
public final class P {