Add check already fixed variables in PostponedArgumentInputTypesResolver during adding constraints on them and using inside a functional type
^KT-42374 Fixed
This commit is contained in:
+5
@@ -11085,6 +11085,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt")
|
||||||
|
public void testFixingVariableDuringAddingConstraintForFirstPosponedArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lackOfDeepIncorporation.kt")
|
@TestMetadata("lackOfDeepIncorporation.kt")
|
||||||
public void testLackOfDeepIncorporation() throws Exception {
|
public void testLackOfDeepIncorporation() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
||||||
|
|||||||
+1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
|||||||
interface ConstraintSystemCompletionContext : VariableFixationFinder.Context, ResultTypeResolver.Context {
|
interface ConstraintSystemCompletionContext : VariableFixationFinder.Context, ResultTypeResolver.Context {
|
||||||
val allTypeVariables: Map<TypeConstructorMarker, TypeVariableMarker>
|
val allTypeVariables: Map<TypeConstructorMarker, TypeVariableMarker>
|
||||||
override val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
override val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
||||||
|
override val fixedTypeVariables: Map<TypeConstructorMarker, KotlinTypeMarker>
|
||||||
override val postponedTypeVariables: List<TypeVariableMarker>
|
override val postponedTypeVariables: List<TypeVariableMarker>
|
||||||
|
|
||||||
fun getBuilder(): ConstraintSystemBuilder
|
fun getBuilder(): ConstraintSystemBuilder
|
||||||
|
|||||||
+1
@@ -20,6 +20,7 @@ class VariableFixationFinder(
|
|||||||
) {
|
) {
|
||||||
interface Context : TypeSystemInferenceExtensionContext {
|
interface Context : TypeSystemInferenceExtensionContext {
|
||||||
val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
val notFixedTypeVariables: Map<TypeConstructorMarker, VariableWithConstraints>
|
||||||
|
val fixedTypeVariables: Map<TypeConstructorMarker, KotlinTypeMarker>
|
||||||
val postponedTypeVariables: List<TypeVariableMarker>
|
val postponedTypeVariables: List<TypeVariableMarker>
|
||||||
fun isReified(variable: TypeVariableMarker): Boolean
|
fun isReified(variable: TypeVariableMarker): Boolean
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-1
@@ -220,9 +220,12 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
|
|
||||||
return allGroupedParameterTypes.mapIndexed { index, types ->
|
return allGroupedParameterTypes.mapIndexed { index, types ->
|
||||||
val parameterTypeVariable = createTypeVariableForParameterType(argument, index)
|
val parameterTypeVariable = createTypeVariableForParameterType(argument, index)
|
||||||
|
val typeVariableConstructor = parameterTypeVariable.freshTypeConstructor
|
||||||
|
|
||||||
for (typeWithKind in types) {
|
for (typeWithKind in types) {
|
||||||
|
if (typeVariableConstructor in fixedTypeVariables) break
|
||||||
if (typeWithKind == null) continue
|
if (typeWithKind == null) continue
|
||||||
|
|
||||||
when (typeWithKind.direction) {
|
when (typeWithKind.direction) {
|
||||||
ConstraintKind.EQUALITY -> csBuilder.addEqualityConstraint(
|
ConstraintKind.EQUALITY -> csBuilder.addEqualityConstraint(
|
||||||
parameterTypeVariable.defaultType, typeWithKind.type, ArgumentConstraintPositionImpl(atom)
|
parameterTypeVariable.defaultType, typeWithKind.type, ArgumentConstraintPositionImpl(atom)
|
||||||
@@ -236,7 +239,13 @@ class PostponedArgumentInputTypesResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parameterTypeVariable.defaultType.asTypeProjection()
|
val resultType = if (typeVariableConstructor in fixedTypeVariables) {
|
||||||
|
fixedTypeVariables[typeVariableConstructor] as KotlinType
|
||||||
|
} else {
|
||||||
|
parameterTypeVariable.defaultType
|
||||||
|
}
|
||||||
|
|
||||||
|
resultType.asTypeProjection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||||
|
|
||||||
|
fun f(p: (Int) -> (String) -> Unit) {}
|
||||||
|
|
||||||
|
fun g(cond: Boolean) {
|
||||||
|
f(if (cond) { i -> { } } else { i -> { } })
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun f(/*0*/ p: (kotlin.Int) -> (kotlin.String) -> kotlin.Unit): kotlin.Unit
|
||||||
|
public fun g(/*0*/ cond: kotlin.Boolean): kotlin.Unit
|
||||||
@@ -11092,6 +11092,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt")
|
||||||
|
public void testFixingVariableDuringAddingConstraintForFirstPosponedArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lackOfDeepIncorporation.kt")
|
@TestMetadata("lackOfDeepIncorporation.kt")
|
||||||
public void testLackOfDeepIncorporation() throws Exception {
|
public void testLackOfDeepIncorporation() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
||||||
|
|||||||
Generated
+5
@@ -11087,6 +11087,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/callableReferences.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt")
|
||||||
|
public void testFixingVariableDuringAddingConstraintForFirstPosponedArgument() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/fixingVariableDuringAddingConstraintForFirstPosponedArgument.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("lackOfDeepIncorporation.kt")
|
@TestMetadata("lackOfDeepIncorporation.kt")
|
||||||
public void testLackOfDeepIncorporation() throws Exception {
|
public void testLackOfDeepIncorporation() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/lackOfDeepIncorporation.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user