FIR: Adjust override checker to definitely-not-nullable types
^KT-52201 Related
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user