[FIR Java] Look into type arguments during dependent type parameter search
This commit is contained in:
@@ -75,7 +75,12 @@ class JavaOverrideChecker internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun FirTypeRef?.isTypeParameterDependent(): Boolean =
|
private fun FirTypeRef?.isTypeParameterDependent(): Boolean =
|
||||||
this is FirResolvedTypeRef && type.lowerBoundIfFlexible() is ConeTypeParameterType
|
this is FirResolvedTypeRef && type.lowerBoundIfFlexible().isTypeParameterDependent()
|
||||||
|
|
||||||
|
private fun ConeKotlinType.isTypeParameterDependent(): Boolean =
|
||||||
|
this is ConeTypeParameterType || this is ConeClassLikeType && typeArguments.any { argument ->
|
||||||
|
argument is ConeKotlinTypeProjection && argument.type.isTypeParameterDependent()
|
||||||
|
}
|
||||||
|
|
||||||
private fun FirCallableMemberDeclaration<*>.isTypeParameterDependent(): Boolean =
|
private fun FirCallableMemberDeclaration<*>.isTypeParameterDependent(): Boolean =
|
||||||
typeParameters.isNotEmpty() || returnTypeRef.isTypeParameterDependent() ||
|
typeParameters.isNotEmpty() || returnTypeRef.isTypeParameterDependent() ||
|
||||||
@@ -84,8 +89,21 @@ class JavaOverrideChecker internal constructor(
|
|||||||
|
|
||||||
private fun FirTypeRef.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
|
private fun FirTypeRef.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
|
||||||
if (this is FirResolvedTypeRef) {
|
if (this is FirResolvedTypeRef) {
|
||||||
(type.lowerBoundIfFlexible() as? ConeTypeParameterType)?.lookupTag?.typeParameterSymbol?.fir?.let {
|
type.lowerBoundIfFlexible().extractTypeParametersTo(result)
|
||||||
result += it
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ConeKotlinType.extractTypeParametersTo(result: MutableCollection<FirTypeParameterRef>) {
|
||||||
|
when (this) {
|
||||||
|
is ConeTypeParameterType -> {
|
||||||
|
result += lookupTag.typeParameterSymbol.fir
|
||||||
|
}
|
||||||
|
is ConeClassLikeType -> typeArguments.forEach {
|
||||||
|
if (it is ConeKotlinTypeProjection) {
|
||||||
|
it.type.extractTypeParametersTo(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user