[NI] Invoke checkType for arguments
checkType performs various actions required by BE (e.g., record nullability assertions information for JVM BE).
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
dc453e6d8b
commit
5b2e66f0ca
+13
-6
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
|||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
import org.jetbrains.kotlin.types.expressions.DataFlowAnalyzer
|
||||||
|
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
@@ -227,7 +228,6 @@ class KotlinToResolvedCallTransformer(
|
|||||||
|
|
||||||
val argumentExpression = valueArgument.getArgumentExpression() ?: continue
|
val argumentExpression = valueArgument.getArgumentExpression() ?: continue
|
||||||
updateRecordedType(argumentExpression, newContext)
|
updateRecordedType(argumentExpression, newContext)
|
||||||
// dataFlowAnalyzer.checkType(updatedType, deparenthesized, newContext)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -243,10 +243,7 @@ class KotlinToResolvedCallTransformer(
|
|||||||
val recordedType = context.trace.getType(deparenthesized)
|
val recordedType = context.trace.getType(deparenthesized)
|
||||||
var updatedType = recordedType
|
var updatedType = recordedType
|
||||||
|
|
||||||
val resolvedCall = deparenthesized.getResolvedCall(context.trace.bindingContext)
|
updatedType = getResolvedCallForArgumentExpression(deparenthesized, context)?.run { resultingDescriptor.returnType } ?: updatedType
|
||||||
if (resolvedCall != null) {
|
|
||||||
updatedType = resolvedCall.resultingDescriptor.returnType ?: updatedType
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the cases like 'foo(1)' the type of '1' depends on expected type (it can be Int, Byte, etc.),
|
// For the cases like 'foo(1)' the type of '1' depends on expected type (it can be Int, Byte, etc.),
|
||||||
// so while the expected type is not known, it's IntegerValueType(1), and should be updated when the expected type is known.
|
// so while the expected type is not known, it's IntegerValueType(1), and should be updated when the expected type is known.
|
||||||
@@ -254,9 +251,19 @@ class KotlinToResolvedCallTransformer(
|
|||||||
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, deparenthesized) ?: updatedType
|
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, deparenthesized) ?: updatedType
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateRecordedTypeForArgument(updatedType, recordedType, expression, context)
|
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context)
|
||||||
|
|
||||||
|
dataFlowAnalyzer.checkType(updatedType, deparenthesized, context)
|
||||||
|
|
||||||
|
return updatedType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getResolvedCallForArgumentExpression(expression: KtExpression, context: BasicCallResolutionContext) =
|
||||||
|
if (!ExpressionTypingUtils.dependsOnExpectedType(expression))
|
||||||
|
null
|
||||||
|
else
|
||||||
|
expression.getResolvedCall(context.trace.bindingContext)
|
||||||
|
|
||||||
// See CallCompleter#updateRecordedTypeForArgument
|
// See CallCompleter#updateRecordedTypeForArgument
|
||||||
private fun updateRecordedTypeForArgument(
|
private fun updateRecordedTypeForArgument(
|
||||||
updatedType: KotlinType?,
|
updatedType: KotlinType?,
|
||||||
|
|||||||
Reference in New Issue
Block a user