[FIR] Properly approximate return type of callable declarations

- approximate intersection types in all non-local declarations
- approximate local types in non-private non-local declarations
This commit is contained in:
Dmitriy Novozhilov
2022-11-10 15:34:40 +02:00
committed by Space Team
parent 0f70635fcb
commit 01c6c7dc59
19 changed files with 190 additions and 230 deletions
@@ -112,7 +112,7 @@ private fun ConeKotlinType.needLocalTypeApproximation(
session: FirSession,
useSitePosition: PsiElement
): Boolean {
if (!shouldApproximateLocalTypesOfNonLocalDeclaration(visibilityForApproximation, isInlineFunction)) return false
if (!shouldApproximateAnonymousTypesOfNonLocalDeclaration(visibilityForApproximation, isInlineFunction)) return false
val localTypes: List<ConeKotlinType> = if (isLocal(session)) listOf(this) else {
typeArguments.mapNotNull {
if (it is ConeKotlinTypeProjection && it.type.isLocal(session)) {
@@ -1,17 +1,12 @@
[direct super types]
A
B
kotlin.Any
[approximated direct super types]
A
B
kotlin.Any
[all super types]
A
B
kotlin.Any
[approximated all super types]
A
B
kotlin.Any
@@ -38397,6 +38397,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt");
}
@Test
@TestMetadata("moreOnlyInputTypes.kt")
public void testMoreOnlyInputTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/moreOnlyInputTypes.kt");
}
@Test
@TestMetadata("noInferAndLowPriority.kt")
public void testNoInferAndLowPriority() throws Exception {