[FIR] Analyze bodies of non delegated property accessors without expected type

^KT-53349 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-09-20 11:28:34 +03:00
parent c5fd248e69
commit a6c7d4c0c6
7 changed files with 49 additions and 1 deletions
@@ -3437,6 +3437,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("getterWithEarlyReturn.kt")
public void testGetterWithEarlyReturn() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properties/getterWithEarlyReturn.kt");
}
@Test
@TestMetadata("javaAccessorConversion.kt")
public void testJavaAccessorConversion() throws Exception {
@@ -3030,6 +3030,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("getterWithEarlyReturn.kt")
public void testGetterWithEarlyReturn() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properties/getterWithEarlyReturn.kt");
}
@TestMetadata("javaAccessorConversion.kt")
public void testJavaAccessorConversion() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properties/javaAccessorConversion.kt");
@@ -0,0 +1,14 @@
FILE: getterWithEarlyReturn.kt
public final class SomeClass : R|kotlin/Any| {
public constructor(): R|SomeClass| {
super<R|kotlin/Any|>()
}
}
public final val R|SomeClass|.lore: R|kotlin/collections/List<kotlin/String>|
public get(): R|kotlin/collections/List<kotlin/String>| {
this@R|/lore|.R|kotlin/apply|<R|SomeClass|>(<L> = apply@fun R|SomeClass|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE> {
^ R|kotlin/collections/emptyList|<R|kotlin/String|>()
}
)
}
@@ -0,0 +1,11 @@
// WITH_STDLIB
// ISSUE: KT-53349
class SomeClass
val SomeClass.lore: List<String>
get() {
apply {
return emptyList()
}
}
@@ -3437,6 +3437,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("getterWithEarlyReturn.kt")
public void testGetterWithEarlyReturn() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properties/getterWithEarlyReturn.kt");
}
@Test
@TestMetadata("javaAccessorConversion.kt")
public void testJavaAccessorConversion() throws Exception {
@@ -3437,6 +3437,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/properties"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("getterWithEarlyReturn.kt")
public void testGetterWithEarlyReturn() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/properties/getterWithEarlyReturn.kt");
}
@Test
@TestMetadata("javaAccessorConversion.kt")
public void testJavaAccessorConversion() throws Exception {
@@ -459,7 +459,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
} else {
returnTypeRef
}
val resolutionMode = if (expectedReturnTypeRef.coneTypeSafe<ConeKotlinType>() == session.builtinTypes.unitType.type) {
val resolutionMode = if (owner.delegate == null || expectedReturnTypeRef.coneTypeSafe<ConeKotlinType>()?.isUnit == true) {
ResolutionMode.ContextIndependent
} else {
withExpectedType(expectedReturnTypeRef)