K2/MPP: treat Array<Some> & Array<out Some> as similar types in annotations
#KT-59561 Fixed Related to KT-61100
This commit is contained in:
committed by
Space Team
parent
f085d0f660
commit
9f6abfc166
+25
-1
@@ -334,7 +334,11 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
override val TypeParameterSymbolMarker.isReified: Boolean
|
||||
get() = asIr().isReified
|
||||
|
||||
override fun areCompatibleExpectActualTypes(expectType: KotlinTypeMarker?, actualType: KotlinTypeMarker?): Boolean {
|
||||
override fun areCompatibleExpectActualTypes(
|
||||
expectType: KotlinTypeMarker?,
|
||||
actualType: KotlinTypeMarker?,
|
||||
parameterOfAnnotationComparisonMode: Boolean,
|
||||
): Boolean {
|
||||
if (expectType == null) return actualType == null
|
||||
if (actualType == null) return false
|
||||
/*
|
||||
@@ -355,6 +359,17 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
*/
|
||||
val actualizedExpectType = expectType.actualize()
|
||||
val actualizedActualType = actualType.actualize()
|
||||
|
||||
if (parameterOfAnnotationComparisonMode && actualizedExpectType is IrSimpleType && actualizedExpectType.isArray() &&
|
||||
actualizedActualType is IrSimpleType && actualizedActualType.isArray()
|
||||
) {
|
||||
return AbstractTypeChecker.equalTypes(
|
||||
createTypeCheckerState(),
|
||||
actualizedExpectType.convertToArrayWithOutProjections(),
|
||||
actualizedActualType.convertToArrayWithOutProjections()
|
||||
)
|
||||
}
|
||||
|
||||
return AbstractTypeChecker.equalTypes(
|
||||
createTypeCheckerState(),
|
||||
actualizedExpectType,
|
||||
@@ -362,6 +377,15 @@ internal abstract class IrExpectActualMatchingContext(
|
||||
)
|
||||
}
|
||||
|
||||
private fun IrSimpleType.convertToArrayWithOutProjections(): IrSimpleType {
|
||||
val argumentsWithOutProjection = List(arguments.size) { i ->
|
||||
val typeArgument = arguments[i]
|
||||
if (typeArgument !is IrSimpleType) typeArgument
|
||||
else makeTypeProjection(typeArgument, Variance.OUT_VARIANCE)
|
||||
}
|
||||
return IrSimpleTypeImpl(classifier, isNullable(), argumentsWithOutProjection, annotations)
|
||||
}
|
||||
|
||||
private fun createTypeCheckerState(): TypeCheckerState {
|
||||
return typeContext.newTypeCheckerState(errorTypesEqualToAnything = true, stubTypesEqualToAnything = false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user