Minor. Reformat some inference files
This commit is contained in:
committed by
Space Team
parent
9a6bff958f
commit
c163f86ecb
+9
-9
@@ -50,7 +50,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
candidateReturnType: ConeKotlinType,
|
candidateReturnType: ConeKotlinType,
|
||||||
context: ResolutionContext,
|
context: ResolutionContext,
|
||||||
collectVariablesFromContext: Boolean = false,
|
collectVariablesFromContext: Boolean = false,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit,
|
||||||
) = c.runCompletion(completionMode, topLevelAtoms, candidateReturnType, context, collectVariablesFromContext, analyze)
|
) = c.runCompletion(completionMode, topLevelAtoms, candidateReturnType, context, collectVariablesFromContext, analyze)
|
||||||
|
|
||||||
private fun ConstraintSystemCompletionContext.runCompletion(
|
private fun ConstraintSystemCompletionContext.runCompletion(
|
||||||
@@ -59,7 +59,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
topLevelType: ConeKotlinType,
|
topLevelType: ConeKotlinType,
|
||||||
context: ResolutionContext,
|
context: ResolutionContext,
|
||||||
collectVariablesFromContext: Boolean = false,
|
collectVariablesFromContext: Boolean = false,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit,
|
||||||
) {
|
) {
|
||||||
val topLevelTypeVariables = topLevelType.extractTypeVariables()
|
val topLevelTypeVariables = topLevelType.extractTypeVariables()
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
topLevelType: ConeKotlinType,
|
topLevelType: ConeKotlinType,
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
allTypeVariables: List<TypeConstructorMarker>,
|
allTypeVariables: List<TypeConstructorMarker>,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (completionMode != ConstraintSystemCompletionMode.FULL) return false
|
if (completionMode != ConstraintSystemCompletionMode.FULL) return false
|
||||||
|
|
||||||
@@ -349,7 +349,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
|
|
||||||
private fun ConstraintSystemCompletionContext.getOrderedAllTypeVariables(
|
private fun ConstraintSystemCompletionContext.getOrderedAllTypeVariables(
|
||||||
collectVariablesFromContext: Boolean,
|
collectVariablesFromContext: Boolean,
|
||||||
topLevelAtoms: List<FirStatement>
|
topLevelAtoms: List<FirStatement>,
|
||||||
): List<TypeConstructorMarker> {
|
): List<TypeConstructorMarker> {
|
||||||
if (collectVariablesFromContext) {
|
if (collectVariablesFromContext) {
|
||||||
return notFixedTypeVariables.keys.toList()
|
return notFixedTypeVariables.keys.toList()
|
||||||
@@ -425,7 +425,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
|
|
||||||
private fun fixVariable(
|
private fun fixVariable(
|
||||||
c: ConstraintSystemCompletionContext,
|
c: ConstraintSystemCompletionContext,
|
||||||
variableWithConstraints: VariableWithConstraints
|
variableWithConstraints: VariableWithConstraints,
|
||||||
) {
|
) {
|
||||||
val resultType = inferenceComponents.resultTypeResolver.findResultType(
|
val resultType = inferenceComponents.resultTypeResolver.findResultType(
|
||||||
c,
|
c,
|
||||||
@@ -461,7 +461,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
|
|
||||||
private fun findResolvedAtomBy(
|
private fun findResolvedAtomBy(
|
||||||
typeVariable: TypeVariableMarker,
|
typeVariable: TypeVariableMarker,
|
||||||
topLevelAtoms: List<FirStatement>
|
topLevelAtoms: List<FirStatement>,
|
||||||
): FirStatement? {
|
): FirStatement? {
|
||||||
|
|
||||||
fun FirStatement.findFirstAtomContainingVariable(): FirStatement? {
|
fun FirStatement.findFirstAtomContainingVariable(): FirStatement? {
|
||||||
@@ -497,7 +497,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
private fun createCannotInferErrorType(
|
private fun createCannotInferErrorType(
|
||||||
typeParameterSymbol: FirTypeParameterSymbol?,
|
typeParameterSymbol: FirTypeParameterSymbol?,
|
||||||
message: String,
|
message: String,
|
||||||
isUninferredParameter: Boolean = false
|
isUninferredParameter: Boolean = false,
|
||||||
): ConeErrorType {
|
): ConeErrorType {
|
||||||
val diagnostic = when (typeParameterSymbol) {
|
val diagnostic = when (typeParameterSymbol) {
|
||||||
null -> ConeSimpleDiagnostic(message, DiagnosticKind.CannotInferParameterType)
|
null -> ConeSimpleDiagnostic(message, DiagnosticKind.CannotInferParameterType)
|
||||||
@@ -506,7 +506,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
message,
|
message,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return ConeErrorType(diagnostic, isUninferredParameter,)
|
return ConeErrorType(diagnostic, isUninferredParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -576,7 +576,7 @@ fun FirStatement.processAllContainingCallCandidates(processBlocks: Boolean, proc
|
|||||||
|
|
||||||
private fun FirResolvable.processCandidateIfApplicable(
|
private fun FirResolvable.processCandidateIfApplicable(
|
||||||
processor: (Candidate) -> Unit,
|
processor: (Candidate) -> Unit,
|
||||||
processBlocks: Boolean
|
processBlocks: Boolean,
|
||||||
) {
|
) {
|
||||||
val candidate = (calleeReference as? FirNamedReferenceWithCandidate)?.candidate ?: return
|
val candidate = (calleeReference as? FirNamedReferenceWithCandidate)?.candidate ?: return
|
||||||
processor(candidate)
|
processor(candidate)
|
||||||
|
|||||||
+1
-1
@@ -244,7 +244,7 @@ fun LambdaWithTypeVariableAsExpectedTypeAtom.transformToResolvedLambda(
|
|||||||
csBuilder: ConstraintSystemBuilder,
|
csBuilder: ConstraintSystemBuilder,
|
||||||
context: ResolutionContext,
|
context: ResolutionContext,
|
||||||
expectedType: ConeKotlinType? = null,
|
expectedType: ConeKotlinType? = null,
|
||||||
returnTypeVariable: ConeTypeVariableForLambdaReturnType? = null
|
returnTypeVariable: ConeTypeVariableForLambdaReturnType? = null,
|
||||||
): ResolvedLambdaAtom {
|
): ResolvedLambdaAtom {
|
||||||
val fixedExpectedType = (csBuilder.buildCurrentSubstitutor() as ConeSubstitutor)
|
val fixedExpectedType = (csBuilder.buildCurrentSubstitutor() as ConeSubstitutor)
|
||||||
.substituteOrSelf(expectedType ?: this.expectedType)
|
.substituteOrSelf(expectedType ?: this.expectedType)
|
||||||
|
|||||||
+11
-11
@@ -30,8 +30,7 @@ class NewConstraintSystemImpl(
|
|||||||
ConstraintSystemBuilder,
|
ConstraintSystemBuilder,
|
||||||
ConstraintInjector.Context,
|
ConstraintInjector.Context,
|
||||||
ResultTypeResolver.Context,
|
ResultTypeResolver.Context,
|
||||||
PostponedArgumentsAnalyzerContext
|
PostponedArgumentsAnalyzerContext {
|
||||||
{
|
|
||||||
private val utilContext = constraintInjector.constraintIncorporator.utilContext
|
private val utilContext = constraintInjector.constraintIncorporator.utilContext
|
||||||
|
|
||||||
private val postponedComputationsAfterAllVariablesAreFixed = mutableListOf<() -> Unit>()
|
private val postponedComputationsAfterAllVariablesAreFixed = mutableListOf<() -> Unit>()
|
||||||
@@ -122,7 +121,7 @@ class NewConstraintSystemImpl(
|
|||||||
|
|
||||||
override fun addMissedConstraints(
|
override fun addMissedConstraints(
|
||||||
position: IncorporationConstraintPosition,
|
position: IncorporationConstraintPosition,
|
||||||
constraints: MutableList<Pair<TypeVariableMarker, Constraint>>
|
constraints: MutableList<Pair<TypeVariableMarker, Constraint>>,
|
||||||
) {
|
) {
|
||||||
storage.missedConstraints.add(position to constraints)
|
storage.missedConstraints.add(position to constraints)
|
||||||
}
|
}
|
||||||
@@ -172,21 +171,22 @@ class NewConstraintSystemImpl(
|
|||||||
override fun putBuiltFunctionalExpectedTypeForPostponedArgument(
|
override fun putBuiltFunctionalExpectedTypeForPostponedArgument(
|
||||||
topLevelVariable: TypeConstructorMarker,
|
topLevelVariable: TypeConstructorMarker,
|
||||||
pathToExpectedType: List<Pair<TypeConstructorMarker, Int>>,
|
pathToExpectedType: List<Pair<TypeConstructorMarker, Int>>,
|
||||||
builtFunctionalType: KotlinTypeMarker
|
builtFunctionalType: KotlinTypeMarker,
|
||||||
) {
|
) {
|
||||||
storage.builtFunctionalTypesForPostponedArgumentsByTopLevelTypeVariables[topLevelVariable to pathToExpectedType] = builtFunctionalType
|
storage.builtFunctionalTypesForPostponedArgumentsByTopLevelTypeVariables[topLevelVariable to pathToExpectedType] =
|
||||||
|
builtFunctionalType
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun putBuiltFunctionalExpectedTypeForPostponedArgument(
|
override fun putBuiltFunctionalExpectedTypeForPostponedArgument(
|
||||||
expectedTypeVariable: TypeConstructorMarker,
|
expectedTypeVariable: TypeConstructorMarker,
|
||||||
builtFunctionalType: KotlinTypeMarker
|
builtFunctionalType: KotlinTypeMarker,
|
||||||
) {
|
) {
|
||||||
storage.builtFunctionalTypesForPostponedArgumentsByExpectedTypeVariables[expectedTypeVariable] = builtFunctionalType
|
storage.builtFunctionalTypesForPostponedArgumentsByExpectedTypeVariables[expectedTypeVariable] = builtFunctionalType
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getBuiltFunctionalExpectedTypeForPostponedArgument(
|
override fun getBuiltFunctionalExpectedTypeForPostponedArgument(
|
||||||
topLevelVariable: TypeConstructorMarker,
|
topLevelVariable: TypeConstructorMarker,
|
||||||
pathToExpectedType: List<Pair<TypeConstructorMarker, Int>>
|
pathToExpectedType: List<Pair<TypeConstructorMarker, Int>>,
|
||||||
) = storage.builtFunctionalTypesForPostponedArgumentsByTopLevelTypeVariables[topLevelVariable to pathToExpectedType]
|
) = storage.builtFunctionalTypesForPostponedArgumentsByTopLevelTypeVariables[topLevelVariable to pathToExpectedType]
|
||||||
|
|
||||||
override fun getBuiltFunctionalExpectedTypeForPostponedArgument(expectedTypeVariable: TypeConstructorMarker) =
|
override fun getBuiltFunctionalExpectedTypeForPostponedArgument(expectedTypeVariable: TypeConstructorMarker) =
|
||||||
@@ -479,7 +479,7 @@ class NewConstraintSystemImpl(
|
|||||||
*/
|
*/
|
||||||
private fun applyConstraintsFromFirstSuccessfulBranchOfTheFork(
|
private fun applyConstraintsFromFirstSuccessfulBranchOfTheFork(
|
||||||
forkPointData: ForkPointData,
|
forkPointData: ForkPointData,
|
||||||
position: IncorporationConstraintPosition
|
position: IncorporationConstraintPosition,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return forkPointData.any { constraintSetForForkBranch ->
|
return forkPointData.any { constraintSetForForkBranch ->
|
||||||
runTransaction {
|
runTransaction {
|
||||||
@@ -508,7 +508,7 @@ class NewConstraintSystemImpl(
|
|||||||
override fun fixVariable(
|
override fun fixVariable(
|
||||||
variable: TypeVariableMarker,
|
variable: TypeVariableMarker,
|
||||||
resultType: KotlinTypeMarker,
|
resultType: KotlinTypeMarker,
|
||||||
position: FixVariableConstraintPosition<*>
|
position: FixVariableConstraintPosition<*>,
|
||||||
) = with(utilContext) {
|
) = with(utilContext) {
|
||||||
checkState(State.BUILDING, State.COMPLETION)
|
checkState(State.BUILDING, State.COMPLETION)
|
||||||
|
|
||||||
@@ -607,7 +607,7 @@ class NewConstraintSystemImpl(
|
|||||||
|
|
||||||
private fun ConstraintSystemUtilContext.postponeOnlyInputTypesCheck(
|
private fun ConstraintSystemUtilContext.postponeOnlyInputTypesCheck(
|
||||||
variableWithConstraints: MutableVariableWithConstraints?,
|
variableWithConstraints: MutableVariableWithConstraints?,
|
||||||
resultType: KotlinTypeMarker
|
resultType: KotlinTypeMarker,
|
||||||
) {
|
) {
|
||||||
if (variableWithConstraints != null && variableWithConstraints.typeVariable.hasOnlyInputTypesAttribute()) {
|
if (variableWithConstraints != null && variableWithConstraints.typeVariable.hasOnlyInputTypesAttribute()) {
|
||||||
postponedComputationsAfterAllVariablesAreFixed.add { checkOnlyInputTypesAnnotation(variableWithConstraints, resultType) }
|
postponedComputationsAfterAllVariablesAreFixed.add { checkOnlyInputTypesAnnotation(variableWithConstraints, resultType) }
|
||||||
@@ -623,7 +623,7 @@ class NewConstraintSystemImpl(
|
|||||||
private fun KotlinTypeMarker.substituteAndApproximateIfNecessary(
|
private fun KotlinTypeMarker.substituteAndApproximateIfNecessary(
|
||||||
substitutor: TypeSubstitutorMarker,
|
substitutor: TypeSubstitutorMarker,
|
||||||
approximator: AbstractTypeApproximator,
|
approximator: AbstractTypeApproximator,
|
||||||
constraintKind: ConstraintKind
|
constraintKind: ConstraintKind,
|
||||||
): KotlinTypeMarker {
|
): KotlinTypeMarker {
|
||||||
val doesInputTypeContainsOtherVariables = this.contains { it.typeConstructor() is TypeVariableTypeConstructorMarker }
|
val doesInputTypeContainsOtherVariables = this.contains { it.typeConstructor() is TypeVariableTypeConstructorMarker }
|
||||||
val substitutedType = if (doesInputTypeContainsOtherVariables) substitutor.safeSubstitute(this) else this
|
val substitutedType = if (doesInputTypeContainsOtherVariables) substitutor.safeSubstitute(this) else this
|
||||||
|
|||||||
Reference in New Issue
Block a user