FIR: Adjust override checker to definitely-not-nullable types

^KT-52201 Related
This commit is contained in:
Denis.Zharkov
2022-04-27 10:05:16 +03:00
committed by teamcity
parent 21b86123e8
commit c766f20554
8 changed files with 67 additions and 10 deletions
@@ -153,12 +153,16 @@ class JavaOverrideChecker internal constructor(
}
private fun FirTypeRef?.isTypeParameterDependent(): Boolean =
this is FirResolvedTypeRef && type.lowerBoundIfFlexible().isTypeParameterDependent()
this is FirResolvedTypeRef && type.isTypeParameterDependent()
private fun ConeKotlinType.isTypeParameterDependent(): Boolean =
this is ConeTypeParameterType || this is ConeClassLikeType && typeArguments.any { argument ->
private fun ConeKotlinType.isTypeParameterDependent(): Boolean {
if (this is ConeFlexibleType) return lowerBound.isTypeParameterDependent()
if (this is ConeDefinitelyNotNullType) return original.isTypeParameterDependent()
return this is ConeTypeParameterType || this is ConeClassLikeType && typeArguments.any { argument ->
argument is ConeKotlinTypeProjection && argument.type.isTypeParameterDependent()
}
}
private fun FirCallableDeclaration.isTypeParameterDependent(): Boolean =
typeParameters.isNotEmpty() || returnTypeRef.isTypeParameterDependent() ||
@@ -167,12 +171,14 @@ class JavaOverrideChecker internal constructor(
private fun FirTypeRef.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
if (this is FirResolvedTypeRef) {
type.lowerBoundIfFlexible().extractTypeParametersTo(result)
type.extractTypeParametersTo(result)
}
}
private fun ConeKotlinType.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
when (this) {
is ConeFlexibleType -> lowerBound.extractTypeParametersTo(result)
is ConeDefinitelyNotNullType -> original.extractTypeParametersTo(result)
is ConeTypeParameterType -> {
result += lookupTag.typeParameterSymbol.fir
}