diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.kt b/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.kt new file mode 100644 index 00000000000..6a395b40895 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.kt @@ -0,0 +1,9 @@ +package usage + +class MyType +class MyClass +val MyClass.isInterface get() = 4 + +fun usage(type: MyType) { + type.isInterface() +} diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.txt b/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.txt new file mode 100644 index 00000000000..88b8186bc1d --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.txt @@ -0,0 +1,30 @@ +KT element: KtNameReferenceExpression +FIR element: FirErrorNamedReferenceImpl +FIR source kind: KtRealSourceElementKind + +FIR element rendered: +# + +FIR FILE: +FILE: [ResolvedTo(IMPORTS)] kt60638.kt + package usage + + public final [ResolvedTo(STATUS)] class MyType : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyType] constructor(): R|usage/MyType| { + LAZY_super + } + + } + public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|usage/MyClass| { + LAZY_super + } + + } + public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val R|usage/MyClass|.isInterface: R|kotlin/Int| + public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int| { + ^ Int(4) + } + public final [ResolvedTo(BODY_RESOLVE)] fun usage([ResolvedTo(BODY_RESOLVE)] type: R|usage/MyType|): R|kotlin/Unit| { + R|/type|.#() + } diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java index 328af533d94..6821a521e72 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java @@ -24,6 +24,12 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/getOrBuildFir"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.kt"); + } + @Nested @TestMetadata("analysis/low-level-api-fir/testdata/getOrBuildFir/annotations") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java index 8cf04279506..32f56178e53 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java @@ -24,6 +24,12 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/getOrBuildFir"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/kt60638.kt"); + } + @Nested @TestMetadata("analysis/low-level-api-fir/testdata/getOrBuildFir/annotations") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index d2ca06144cc..20255b6e40c 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -651,6 +651,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/kt58583.kt"); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("compiler/testData/diagnostics/tests/kt60638.kt"); + } + @Test @TestMetadata("LValueAssignment.kt") public void testLValueAssignment() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index be62830bd28..c700271ba0c 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -651,6 +651,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/kt58583.kt"); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("compiler/testData/diagnostics/tests/kt60638.kt"); + } + @Test @TestMetadata("LValueAssignment.kt") public void testLValueAssignment() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 08e1151a94f..05035c484ad 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -651,6 +651,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/kt58583.kt"); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("compiler/testData/diagnostics/tests/kt60638.kt"); + } + @Test @TestMetadata("LValueAssignment.kt") public void testLValueAssignment() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 64e18f4d1f8..37a0848291a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -651,6 +651,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/kt58583.kt"); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("compiler/testData/diagnostics/tests/kt60638.kt"); + } + @Test @TestMetadata("LValueAssignment.kt") public void testLValueAssignment() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 54d2f92b248..f293a0f50b5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -717,7 +717,9 @@ class FirCallResolver( coneType != null && !coneType.isUnit -> { ConeFunctionExpectedError( name.asString(), - (fir as? FirCallableDeclaration)?.returnTypeRef?.coneType ?: coneType + (fir as? FirCallableDeclaration)?.let { + components.returnTypeCalculator.tryCalculateReturnType(it) + }?.coneType ?: coneType ) } singleExpectedCandidate != null && !singleExpectedCandidate.currentApplicability.isSuccess -> { diff --git a/compiler/testData/diagnostics/tests/kt60638.fir.kt b/compiler/testData/diagnostics/tests/kt60638.fir.kt new file mode 100644 index 00000000000..b0bdd7b6235 --- /dev/null +++ b/compiler/testData/diagnostics/tests/kt60638.fir.kt @@ -0,0 +1,9 @@ +package usage + +class MyType +class MyClass +val MyClass.isInterface get() = 4 + +fun usage(type: MyType) { + type.isInterface() +} diff --git a/compiler/testData/diagnostics/tests/kt60638.kt b/compiler/testData/diagnostics/tests/kt60638.kt new file mode 100644 index 00000000000..eb4e9f309ee --- /dev/null +++ b/compiler/testData/diagnostics/tests/kt60638.kt @@ -0,0 +1,9 @@ +package usage + +class MyType +class MyClass +val MyClass.isInterface get() = 4 + +fun usage(type: MyType) { + type.isInterface() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index c61f4ea2be9..8c2f61fb2a7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -651,6 +651,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/kt58583.kt"); } + @Test + @TestMetadata("kt60638.kt") + public void testKt60638() throws Exception { + runTest("compiler/testData/diagnostics/tests/kt60638.kt"); + } + @Test @TestMetadata("LValueAssignment.kt") public void testLValueAssignment() throws Exception {