K2: Rewrite delegate inference

The main idea is getting rid of stub types and using just type variables
See more detailed description at docs/fir/delegated_property_inference.md

The problem with stub types is that they need really special treatment
in many places, and on the other hand, there are no clear contracts on
how they should work (that regularly leads to bugs like KT-59529)

^KT-61060 Fixed
^KT-61075 Fixed
^KT-61077 Fixed
^KT-59529 Fixed
^KT-61633 Related
^KT-61618 Related
^KT-61740 Related
^KT-59107 Related
^KT-61747 Related
^KT-61077 Related
^KT-61781 Related
This commit is contained in:
Denis.Zharkov
2023-08-04 19:52:29 +02:00
committed by Space Team
parent cd5105c133
commit a02cb16fb2
53 changed files with 1183 additions and 381 deletions
@@ -9550,6 +9550,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/useTypeParameterOfExtensionProperty_Disabled.kt");
}
@Test
@TestMetadata("withInvokes.kt")
public void testWithInvokes() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/withInvokes.kt");
}
@Test
@TestMetadata("wrongCountOfParametersInGet.kt")
public void testWrongCountOfParametersInGet() throws Exception {
@@ -9577,6 +9583,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/delegatedProperty/inference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
}
@Test
@TestMetadata("annotatedAccessor.kt")
public void testAnnotatedAccessor() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/annotatedAccessor.kt");
}
@Test
@TestMetadata("callableReferenceArgumentInDelegatedExpression.kt")
public void testCallableReferenceArgumentInDelegatedExpression() throws Exception {
@@ -9625,6 +9637,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt");
}
@Test
@TestMetadata("fullyCompleteDelegateWhenPossible.kt")
public void testFullyCompleteDelegateWhenPossible() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/fullyCompleteDelegateWhenPossible.kt");
}
@Test
@TestMetadata("genericMethodInGenericClass.kt")
public void testGenericMethodInGenericClass() throws Exception {
@@ -9655,6 +9673,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt");
}
@Test
@TestMetadata("lambdaWithMultipleReturns.kt")
public void testLambdaWithMultipleReturns() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/lambdaWithMultipleReturns.kt");
}
@Test
@TestMetadata("manyIncompleteCandidates.kt")
public void testManyIncompleteCandidates() throws Exception {
@@ -9691,12 +9715,36 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/notNullAssertionInLocalDelegated.kt");
}
@Test
@TestMetadata("nothingTypeThisRef.kt")
public void testNothingTypeThisRef() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/nothingTypeThisRef.kt");
}
@Test
@TestMetadata("provideDelegateFixationResultContainsOtherInnerVariable.kt")
public void testProvideDelegateFixationResultContainsOtherInnerVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateFixationResultContainsOtherInnerVariable.kt");
}
@Test
@TestMetadata("provideDelegateReturningOuterTypeVariable.kt")
public void testProvideDelegateReturningOuterTypeVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt");
}
@Test
@TestMetadata("successfulProvideDelegateLeadsToRedGetValue.kt")
public void testSuccessfulProvideDelegateLeadsToRedGetValue() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/successfulProvideDelegateLeadsToRedGetValue.kt");
}
@Test
@TestMetadata("tryInGenerated.kt")
public void testTryInGenerated() throws Exception {
@@ -9709,6 +9757,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeOfLazyDelegatedPropertyWithObject.kt");
}
@Test
@TestMetadata("typeVariablesFlow.kt")
public void testTypeVariablesFlow() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeVariablesFlow.kt");
}
@Test
@TestMetadata("typeVariablesFlowComplex.kt")
public void testTypeVariablesFlowComplex() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeVariablesFlowComplex.kt");
}
@Test
@TestMetadata("useCompleterWithoutExpectedType.kt")
public void testUseCompleterWithoutExpectedType() throws Exception {
@@ -9833,6 +9893,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateResolutionWithStubTypes.kt");
}
@Test
@TestMetadata("provideDelegateResolutionWithStubTypesAndExtensionGetValue.kt")
public void testProvideDelegateResolutionWithStubTypesAndExtensionGetValue() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateResolutionWithStubTypesAndExtensionGetValue.kt");
}
@Test
@TestMetadata("setValue.kt")
public void testSetValue() throws Exception {
@@ -9550,6 +9550,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/useTypeParameterOfExtensionProperty_Disabled.kt");
}
@Test
@TestMetadata("withInvokes.kt")
public void testWithInvokes() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/withInvokes.kt");
}
@Test
@TestMetadata("wrongCountOfParametersInGet.kt")
public void testWrongCountOfParametersInGet() throws Exception {
@@ -9577,6 +9583,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/delegatedProperty/inference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
}
@Test
@TestMetadata("annotatedAccessor.kt")
public void testAnnotatedAccessor() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/annotatedAccessor.kt");
}
@Test
@TestMetadata("callableReferenceArgumentInDelegatedExpression.kt")
public void testCallableReferenceArgumentInDelegatedExpression() throws Exception {
@@ -9625,6 +9637,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt");
}
@Test
@TestMetadata("fullyCompleteDelegateWhenPossible.kt")
public void testFullyCompleteDelegateWhenPossible() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/fullyCompleteDelegateWhenPossible.kt");
}
@Test
@TestMetadata("genericMethodInGenericClass.kt")
public void testGenericMethodInGenericClass() throws Exception {
@@ -9655,6 +9673,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/labeledDelegatedExpression.kt");
}
@Test
@TestMetadata("lambdaWithMultipleReturns.kt")
public void testLambdaWithMultipleReturns() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/lambdaWithMultipleReturns.kt");
}
@Test
@TestMetadata("manyIncompleteCandidates.kt")
public void testManyIncompleteCandidates() throws Exception {
@@ -9691,12 +9715,36 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/notNullAssertionInLocalDelegated.kt");
}
@Test
@TestMetadata("nothingTypeThisRef.kt")
public void testNothingTypeThisRef() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/nothingTypeThisRef.kt");
}
@Test
@TestMetadata("provideDelegateFixationResultContainsOtherInnerVariable.kt")
public void testProvideDelegateFixationResultContainsOtherInnerVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateFixationResultContainsOtherInnerVariable.kt");
}
@Test
@TestMetadata("provideDelegateReturningOuterTypeVariable.kt")
public void testProvideDelegateReturningOuterTypeVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt");
}
@Test
@TestMetadata("successfulProvideDelegateLeadsToRedGetValue.kt")
public void testSuccessfulProvideDelegateLeadsToRedGetValue() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/successfulProvideDelegateLeadsToRedGetValue.kt");
}
@Test
@TestMetadata("tryInGenerated.kt")
public void testTryInGenerated() throws Exception {
@@ -9709,6 +9757,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeOfLazyDelegatedPropertyWithObject.kt");
}
@Test
@TestMetadata("typeVariablesFlow.kt")
public void testTypeVariablesFlow() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeVariablesFlow.kt");
}
@Test
@TestMetadata("typeVariablesFlowComplex.kt")
public void testTypeVariablesFlowComplex() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeVariablesFlowComplex.kt");
}
@Test
@TestMetadata("useCompleterWithoutExpectedType.kt")
public void testUseCompleterWithoutExpectedType() throws Exception {
@@ -9833,6 +9893,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateResolutionWithStubTypes.kt");
}
@Test
@TestMetadata("provideDelegateResolutionWithStubTypesAndExtensionGetValue.kt")
public void testProvideDelegateResolutionWithStubTypesAndExtensionGetValue() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/provideDelegateResolutionWithStubTypesAndExtensionGetValue.kt");
}
@Test
@TestMetadata("setValue.kt")
public void testSetValue() throws Exception {