K2: fix an exception during function resolve #KT-59649 Fixed
This commit is contained in:
committed by
Space Team
parent
d557bcaba4
commit
6bed02fed3
+6
@@ -530,6 +530,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyGetterWithoutType.kt")
|
||||
public void testPropertyGetterWithoutType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyGetterWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierWithCompanion.kt")
|
||||
public void testQualifierWithCompanion() throws Exception {
|
||||
|
||||
+6
@@ -530,6 +530,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyGetterWithoutType.kt")
|
||||
public void testPropertyGetterWithoutType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyGetterWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierWithCompanion.kt")
|
||||
public void testQualifierWithCompanion() throws Exception {
|
||||
|
||||
+5
@@ -449,6 +449,11 @@ public class LazyBodyIsNotTouchedTestGenerated extends AbstractLazyBodyIsNotTouc
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyGetterWithoutType.kt")
|
||||
public void testPropertyGetterWithoutType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyGetterWithoutType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualifierWithCompanion.kt")
|
||||
public void testQualifierWithCompanion() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/qualifierWithCompanion.kt");
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
FILE: propertyGetterWithoutType.kt
|
||||
public final val prop: <ERROR TYPE REF: empty body>
|
||||
public get(): <ERROR TYPE REF: empty body> {
|
||||
local final fun smth(s: R|kotlin/String|): R|kotlin/Int| {
|
||||
^smth Int(1)
|
||||
}
|
||||
|
||||
^ R|<local>/smth|(String(awd))
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// ISSUE: KT-59649
|
||||
val prop
|
||||
get() {
|
||||
fun smth(s: String) = 1
|
||||
return smth("awd")
|
||||
}
|
||||
+6
@@ -530,6 +530,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyGetterWithoutType.kt")
|
||||
public void testPropertyGetterWithoutType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyGetterWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierWithCompanion.kt")
|
||||
public void testQualifierWithCompanion() throws Exception {
|
||||
|
||||
+6
@@ -530,6 +530,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyFromJavaPlusAssign.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyGetterWithoutType.kt")
|
||||
public void testPropertyGetterWithoutType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/propertyGetterWithoutType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierWithCompanion.kt")
|
||||
public void testQualifierWithCompanion() throws Exception {
|
||||
|
||||
+1
-1
@@ -656,7 +656,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
val body = result.body
|
||||
if (result.returnTypeRef is FirImplicitTypeRef) {
|
||||
val simpleFunction = function as? FirSimpleFunction
|
||||
val returnExpression = (body?.statements?.single() as? FirReturnExpression)?.result
|
||||
val returnExpression = (body?.statements?.singleOrNull() as? FirReturnExpression)?.result
|
||||
val returnTypeRef = if (returnExpression?.typeRef is FirResolvedTypeRef) {
|
||||
returnExpression.resultType.approximateDeclarationType(
|
||||
session,
|
||||
|
||||
Reference in New Issue
Block a user