Introduce call checker for Unit-conversions
This commit is contained in:
+2
@@ -75,6 +75,8 @@ object UnitTypeConversions : ParameterTypeConversion {
|
||||
suspendFunction = expectedParameterType.isSuspendFunctionType
|
||||
)
|
||||
|
||||
candidate.resolvedCall.registerArgumentWithUnitConversion(argument, nonUnitReturnedParameterType)
|
||||
|
||||
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
|
||||
|
||||
return nonUnitReturnedParameterType
|
||||
|
||||
@@ -69,6 +69,7 @@ abstract class ResolvedCallAtom : ResolvedAtom() {
|
||||
abstract val knownParametersSubstitutor: TypeSubstitutor
|
||||
abstract val argumentsWithConversion: Map<KotlinCallArgument, SamConversionDescription>
|
||||
abstract val argumentsWithSuspendConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
abstract val argumentsWithUnitConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
abstract val argumentsWithConstantConversion: Map<KotlinCallArgument, IntegerValueTypeConstant>
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -193,6 +193,7 @@ class MutableResolvedCallAtom(
|
||||
lateinit var argumentToCandidateParameter: Map<KotlinCallArgument, ValueParameterDescriptor>
|
||||
private var samAdapterMap: HashMap<KotlinCallArgument, SamConversionDescription>? = null
|
||||
private var suspendAdapterMap: HashMap<KotlinCallArgument, UnwrappedType>? = null
|
||||
private var unitAdapterMap: HashMap<KotlinCallArgument, UnwrappedType>? = null
|
||||
private var signedUnsignedConstantConversions: HashMap<KotlinCallArgument, IntegerValueTypeConstant>? = null
|
||||
|
||||
val hasSamConversion: Boolean
|
||||
@@ -207,6 +208,9 @@ class MutableResolvedCallAtom(
|
||||
override val argumentsWithSuspendConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
get() = suspendAdapterMap ?: emptyMap()
|
||||
|
||||
override val argumentsWithUnitConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
get() = unitAdapterMap ?: emptyMap()
|
||||
|
||||
override val argumentsWithConstantConversion: Map<KotlinCallArgument, IntegerValueTypeConstant>
|
||||
get() = signedUnsignedConstantConversions ?: emptyMap()
|
||||
|
||||
@@ -224,6 +228,13 @@ class MutableResolvedCallAtom(
|
||||
suspendAdapterMap!![argument] = convertedType
|
||||
}
|
||||
|
||||
fun registerArgumentWithUnitConversion(argument: KotlinCallArgument, convertedType: UnwrappedType) {
|
||||
if (unitAdapterMap == null)
|
||||
unitAdapterMap = hashMapOf()
|
||||
|
||||
unitAdapterMap!![argument] = convertedType
|
||||
}
|
||||
|
||||
fun registerArgumentWithConstantConversion(argument: KotlinCallArgument, convertedConstant: IntegerValueTypeConstant) {
|
||||
if (signedUnsignedConstantConversions == null)
|
||||
signedUnsignedConstantConversions = hashMapOf()
|
||||
|
||||
Reference in New Issue
Block a user