K2: Fix exception for PropertyDelegateProvider + lazy case

^KT-63646 Fixed
This commit is contained in:
Denis.Zharkov
2023-11-26 14:13:33 +01:00
committed by Space Team
parent 11d203d0a7
commit bb548e3df4
8 changed files with 82 additions and 4 deletions
@@ -10263,6 +10263,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("provideDelegateUsesOuterCS.kt")
public void testProvideDelegateUsesOuterCS() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateUsesOuterCS.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
@@ -10263,6 +10263,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("provideDelegateUsesOuterCS.kt")
public void testProvideDelegateUsesOuterCS() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateUsesOuterCS.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
@@ -10257,6 +10257,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("provideDelegateUsesOuterCS.kt")
public void testProvideDelegateUsesOuterCS() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateUsesOuterCS.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
@@ -10263,6 +10263,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("provideDelegateUsesOuterCS.kt")
public void testProvideDelegateUsesOuterCS() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateUsesOuterCS.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {
@@ -474,10 +474,6 @@ open class FirDeclarationsResolveTransformer(
val typeVariablesRelatedToProvideDelegate =
allTypeVariables.subList(candidateStorage.outerSystemVariablesPrefixSize, allTypeVariables.size).toSet()
check(typeVariable in typeVariablesRelatedToProvideDelegate) {
"Return type of provideDelegate is expected to be one of the type variables of a candidate, but $typeVariable was found"
}
val variableWithConstraints =
candidateSystem.notFixedTypeVariables[typeVariable] ?: error("Not found type variable $typeVariable")
@@ -0,0 +1,26 @@
// ISSUE: KT-63646
// WITH_STDLIB
interface MyPropertyDelegateProvider<out Y1> {
operator fun provideDelegate(thisRef: Nothing?, property: kotlin.reflect.KProperty<*>): Y1
}
// To look for `getValue` we need to fix Y2 after `provideDelegate` call
fun <Y2> foo(x: () -> Y2): MyPropertyDelegateProvider<Y2> = TODO()
interface MyLazy<X1> {
operator fun getValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>): X1 = TODO()
}
fun <X3> myLazy(x: () -> X3): MyLazy<X3> = TODO()
val property1 by foo {
myLazy { "1" }
}
val property2 by foo {
lazy { "2" } // Regular lazy has `getValue` as an extension
}
fun main() {
property1.length
property2.length
}
@@ -0,0 +1,26 @@
// ISSUE: KT-63646
// WITH_STDLIB
interface MyPropertyDelegateProvider<out Y1> {
operator fun provideDelegate(thisRef: Nothing?, property: kotlin.reflect.KProperty<*>): Y1
}
// To look for `getValue` we need to fix Y2 after `provideDelegate` call
fun <Y2> foo(x: () -> Y2): MyPropertyDelegateProvider<Y2> = TODO()
interface MyLazy<X1> {
operator fun getValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>): X1 = TODO()
}
fun <X3> myLazy(x: () -> X3): MyLazy<X3> = TODO()
val property1 by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>foo {
myLazy { "1" }
}<!>
val property2 by foo {
lazy { "2" } // Regular lazy has `getValue` as an extension
}
fun main() {
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>property1<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>length<!>
property2.length
}
@@ -10263,6 +10263,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateReturningOuterTypeVariable.kt");
}
@Test
@TestMetadata("provideDelegateUsesOuterCS.kt")
public void testProvideDelegateUsesOuterCS() throws Exception {
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/provideDelegateUsesOuterCS.kt");
}
@Test
@TestMetadata("resultTypeOfLambdaForConventionMethods.kt")
public void testResultTypeOfLambdaForConventionMethods() throws Exception {