[NI] Fix inference if inner system has only by "uninteresting" constraint
#KT-32250 fixed
This commit is contained in:
Generated
+5
@@ -10874,6 +10874,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3174.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32250.kt")
|
||||
public void testKt32250() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32250.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32862_both.kt")
|
||||
public void testKt32862_both() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt");
|
||||
|
||||
+5
-2
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage.Empty.hasContradiction
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ExpectedTypeConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
@@ -27,7 +28,8 @@ import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
|
||||
class KotlinCallCompleter(
|
||||
private val postponedArgumentsAnalyzer: PostponedArgumentsAnalyzer,
|
||||
private val kotlinConstraintSystemCompleter: KotlinConstraintSystemCompleter
|
||||
private val kotlinConstraintSystemCompleter: KotlinConstraintSystemCompleter,
|
||||
private val trivialConstraintTypeInferenceOracle: TrivialConstraintTypeInferenceOracle
|
||||
) {
|
||||
|
||||
fun runCompletion(
|
||||
@@ -261,7 +263,8 @@ class KotlinCallCompleter(
|
||||
return constraints.isNotEmpty() && constraints.anyOrAll(requireAll = typeVariable.hasExactAnnotation()) {
|
||||
!it.type.typeConstructor(context).isIntegerLiteralTypeConstructor(context) &&
|
||||
(it.kind.isLower() || it.kind.isEqual()) &&
|
||||
csBuilder.isProperType(it.type)
|
||||
csBuilder.isProperType(it.type) &&
|
||||
!trivialConstraintTypeInferenceOracle.isNotInterestingConstraint(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface I {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
data class Pair<X, Y>(val fst: X, val snd: Y)
|
||||
|
||||
class A(f: Pair<Int, (I) -> Unit>? = null)
|
||||
|
||||
class B(f: ((I) -> Unit)? = null)
|
||||
|
||||
fun main() {
|
||||
val cond = true
|
||||
A(
|
||||
if (cond) {
|
||||
Pair(1, { baz -> baz.foo() })
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
B(
|
||||
if (cond) {
|
||||
{ baz -> baz.foo() }
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package
|
||||
|
||||
public fun main(): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A(/*0*/ f: Pair<kotlin.Int, (I) -> kotlin.Unit>? = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B {
|
||||
public constructor B(/*0*/ f: ((I) -> kotlin.Unit)? = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final data class Pair</*0*/ X, /*1*/ Y> {
|
||||
public constructor Pair</*0*/ X, /*1*/ Y>(/*0*/ fst: X, /*1*/ snd: Y)
|
||||
public final val fst: X
|
||||
public final val snd: Y
|
||||
public final operator /*synthesized*/ fun component1(): X
|
||||
public final operator /*synthesized*/ fun component2(): Y
|
||||
public final /*synthesized*/ fun copy(/*0*/ fst: X = ..., /*1*/ snd: Y = ...): Pair<X, Y>
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -10881,6 +10881,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3174.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32250.kt")
|
||||
public void testKt32250() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32250.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32862_both.kt")
|
||||
public void testKt32862_both() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt");
|
||||
|
||||
Generated
+5
@@ -10876,6 +10876,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt3174.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32250.kt")
|
||||
public void testKt32250() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32250.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32862_both.kt")
|
||||
public void testKt32862_both() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt32862_both.kt");
|
||||
|
||||
Reference in New Issue
Block a user