[FIR] Analyze bodies of non delegated property accessors without expected type
^KT-53349 Fixed
This commit is contained in:
+6
@@ -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 {
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+14
@@ -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|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-53349
|
||||
|
||||
class SomeClass
|
||||
|
||||
val SomeClass.lore: List<String>
|
||||
get() {
|
||||
apply {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
+6
@@ -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 {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user