Extract ConeTypeSubstitutorByTypeConstructor
This commit is contained in:
+7
-12
@@ -223,24 +223,19 @@ fun createTypeSubstitutorByTypeConstructor(
|
|||||||
approximateIntegerLiterals: Boolean
|
approximateIntegerLiterals: Boolean
|
||||||
): ConeSubstitutor {
|
): ConeSubstitutor {
|
||||||
if (map.isEmpty()) return ConeSubstitutor.Empty
|
if (map.isEmpty()) return ConeSubstitutor.Empty
|
||||||
return object : AbstractConeSubstitutor(context), TypeSubstitutorMarker {
|
return ConeTypeSubstitutorByTypeConstructor(map, context, approximateIntegerLiterals)
|
||||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
|
||||||
if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null
|
|
||||||
val new = map[type.typeConstructor(context)] ?: return null
|
|
||||||
val approximatedIntegerLiteralType = if (approximateIntegerLiterals) new.approximateIntegerLiteralType() else new
|
|
||||||
return approximatedIntegerLiteralType.updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TypeSubstitutorByTypeConstructor(
|
internal class ConeTypeSubstitutorByTypeConstructor(
|
||||||
private val map: Map<TypeConstructorMarker, ConeKotlinType>,
|
private val map: Map<TypeConstructorMarker, ConeKotlinType>,
|
||||||
context: ConeTypeContext
|
private val context: ConeTypeContext,
|
||||||
|
private val approximateIntegerLiterals: Boolean
|
||||||
) : AbstractConeSubstitutor(context), TypeSubstitutorMarker {
|
) : AbstractConeSubstitutor(context), TypeSubstitutorMarker {
|
||||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
||||||
if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null
|
if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null
|
||||||
val new = map[type.typeConstructor(typeContext)] ?: return null
|
val new = map[type.typeConstructor(context)] ?: return null
|
||||||
return new.approximateIntegerLiteralType().updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
val approximatedIntegerLiteralType = if (approximateIntegerLiterals) new.approximateIntegerLiteralType() else new
|
||||||
|
return approximatedIntegerLiteralType.updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user