K2: Postpone inference forks resolution until FULL completion
It helps to use expected type information when choosing the branch even in the nested calls ^KT-43296 In Progress
This commit is contained in:
committed by
Space Team
parent
c958c79362
commit
10d63cc52a
+6
@@ -14282,6 +14282,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smartCastForkForExpectedTypeNested.kt")
|
||||||
|
public void testSmartCastForkForExpectedTypeNested() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectedTypeNested.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||||
|
|||||||
+6
@@ -14282,6 +14282,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smartCastForkForExpectedTypeNested.kt")
|
||||||
|
public void testSmartCastForkForExpectedTypeNested() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectedTypeNested.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||||
|
|||||||
+6
@@ -14282,6 +14282,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smartCastForkForExpectedTypeNested.kt")
|
||||||
|
public void testSmartCastForkForExpectedTypeNested() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectedTypeNested.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||||
|
|||||||
+3
-1
@@ -62,7 +62,9 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
) {
|
) {
|
||||||
val topLevelTypeVariables = topLevelType.extractTypeVariables()
|
val topLevelTypeVariables = topLevelType.extractTypeVariables()
|
||||||
|
|
||||||
resolveForkPointsConstraints()
|
if (completionMode == ConstraintSystemCompletionMode.FULL) {
|
||||||
|
resolveForkPointsConstraints()
|
||||||
|
}
|
||||||
|
|
||||||
completion@ while (true) {
|
completion@ while (true) {
|
||||||
// TODO: This is very slow
|
// TODO: This is very slow
|
||||||
|
|||||||
+1
@@ -276,6 +276,7 @@ class NewConstraintSystemImpl(
|
|||||||
storage.errors.addAll(otherSystem.errors)
|
storage.errors.addAll(otherSystem.errors)
|
||||||
storage.fixedTypeVariables.putAll(otherSystem.fixedTypeVariables)
|
storage.fixedTypeVariables.putAll(otherSystem.fixedTypeVariables)
|
||||||
storage.postponedTypeVariables.addAll(otherSystem.postponedTypeVariables)
|
storage.postponedTypeVariables.addAll(otherSystem.postponedTypeVariables)
|
||||||
|
storage.constraintsFromAllForkPoints.addAll(otherSystem.constraintsFromAllForkPoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResultTypeResolver.Context, ConstraintSystemBuilder
|
// ResultTypeResolver.Context, ConstraintSystemBuilder
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
interface Slice<V>
|
||||||
|
|
||||||
|
interface A
|
||||||
|
interface B : A
|
||||||
|
interface C : A
|
||||||
|
|
||||||
|
val SL0: Slice<A> = TODO()
|
||||||
|
val SL1: Slice<B> = TODO()
|
||||||
|
val SL2: Slice<C> = TODO()
|
||||||
|
|
||||||
|
fun <X> foo(s: Slice<X>): X? {
|
||||||
|
if (s.hashCode() == 0) {
|
||||||
|
return id(bar(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s === SL0) {
|
||||||
|
return id(bar(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s === SL1 || s === SL2) {
|
||||||
|
return id(bar(s))
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> id(x: T): T = x
|
||||||
|
|
||||||
|
fun <Y> bar(w: Slice<Y>): Y? = null
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
interface Slice<V>
|
||||||
|
|
||||||
|
interface A
|
||||||
|
interface B : A
|
||||||
|
interface C : A
|
||||||
|
|
||||||
|
val SL0: Slice<A> = TODO()
|
||||||
|
val SL1: Slice<B> = TODO()
|
||||||
|
val SL2: Slice<C> = TODO()
|
||||||
|
|
||||||
|
fun <X> foo(s: Slice<X>): X? {
|
||||||
|
if (s.hashCode() == 0) {
|
||||||
|
return id(bar(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s === SL0) {
|
||||||
|
return <!TYPE_MISMATCH, TYPE_MISMATCH!>id(bar(<!DEBUG_INFO_SMARTCAST!>s<!>))<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s === SL1 || s === SL2) {
|
||||||
|
return id(bar(s))
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> id(x: T): T = x
|
||||||
|
|
||||||
|
fun <Y> bar(w: Slice<Y>): Y? = null
|
||||||
Generated
+6
@@ -14288,6 +14288,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("smartCastForkForExpectedTypeNested.kt")
|
||||||
|
public void testSmartCastForkForExpectedTypeNested() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/smartCastForkForExpectedTypeNested.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user