Extract ConeTypeSubstitutorByTypeConstructor
This commit is contained in:
+8
-13
@@ -223,7 +223,14 @@ 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)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ConeTypeSubstitutorByTypeConstructor(
|
||||||
|
private val map: Map<TypeConstructorMarker, ConeKotlinType>,
|
||||||
|
private val context: ConeTypeContext,
|
||||||
|
private val approximateIntegerLiterals: Boolean
|
||||||
|
) : 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(context)] ?: return null
|
val new = map[type.typeConstructor(context)] ?: return null
|
||||||
@@ -231,18 +238,6 @@ fun createTypeSubstitutorByTypeConstructor(
|
|||||||
return approximatedIntegerLiteralType.updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
return approximatedIntegerLiteralType.updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal class TypeSubstitutorByTypeConstructor(
|
|
||||||
private val map: Map<TypeConstructorMarker, ConeKotlinType>,
|
|
||||||
context: ConeTypeContext
|
|
||||||
) : AbstractConeSubstitutor(context), TypeSubstitutorMarker {
|
|
||||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
|
||||||
if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null
|
|
||||||
val new = map[type.typeConstructor(typeContext)] ?: return null
|
|
||||||
return new.approximateIntegerLiteralType().updateNullabilityIfNeeded(type)?.withCombinedAttributesFrom(type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: builder inference uses TypeSubstitutorByTypeConstructor for not fixed type substitution
|
// Note: builder inference uses TypeSubstitutorByTypeConstructor for not fixed type substitution
|
||||||
class NotFixedTypeToVariableSubstitutorForDelegateInference(
|
class NotFixedTypeToVariableSubstitutorForDelegateInference(
|
||||||
|
|||||||
Reference in New Issue
Block a user