[Analysis API] fix "scope for class ConeClassLikeTypeImpl not found exception" when stdlib is missing

^KT-60641 fixed
This commit is contained in:
Ilya Kirillov
2023-07-24 15:50:35 +02:00
committed by Space Team
parent bfe73567c1
commit cc27bfd39a
6 changed files with 113 additions and 5 deletions
@@ -0,0 +1,3 @@
fun f<caret>oo() {
1.toInt()
}
@@ -0,0 +1,65 @@
RAW_FIR:
FILE: [ResolvedTo(RAW_FIR)] integerLiteralCall.kt
public? final? [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
IMPORTS:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public? final? [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
COMPILER_REQUIRED_ANNOTATIONS:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
COMPANION_GENERATION:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public? final? [ResolvedTo(COMPANION_GENERATION)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
SUPER_TYPES:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public? final? [ResolvedTo(SUPER_TYPES)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
TYPES:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public? final? [ResolvedTo(TYPES)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
STATUS:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(STATUS)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
EXPECT_ACTUAL_MATCHING:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(EXPECT_ACTUAL_MATCHING)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
ARGUMENTS_OF_ANNOTATIONS:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] fun foo(): R|kotlin/Unit| { LAZY_BLOCK }
CONTRACTS:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(CONTRACTS)] fun foo(): R|kotlin/Unit| {
IntegerLiteral(1).toInt#()
}
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun foo(): R|kotlin/Unit| {
IntegerLiteral(1).toInt#()
}
ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] fun foo(): R|kotlin/Unit| {
IntegerLiteral(1).toInt#()
}
BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(BODY_RESOLVE)] fun foo(): R|kotlin/Unit| {
IntegerLiteral(1).<Unresolved name: toInt>#()
}
FILE RAW TO BODY:
FILE: [ResolvedTo(IMPORTS)] integerLiteralCall.kt
public final [ResolvedTo(BODY_RESOLVE)] fun foo(): R|kotlin/Unit| {
IntegerLiteral(1).<Unresolved name: toInt>#()
}
@@ -19,6 +19,8 @@ import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.NO_RUNTIME
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
import org.jetbrains.kotlin.test.services.TestModuleStructure
import org.jetbrains.kotlin.test.services.TestServices
@@ -57,8 +59,16 @@ abstract class AbstractFirLazyDeclarationResolveTest : AbstractFirLazyDeclaratio
override fun configureTest(builder: TestConfigurationBuilder) {
super.configureTest(builder)
with(builder) {
defaultDirectives {
+ConfigurationDirectives.WITH_STDLIB
forTestsNotMatching("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime/*" ) {
defaultDirectives {
+WITH_STDLIB
}
}
forTestsMatching("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime/*") {
defaultDirectives {
+NO_RUNTIME
}
}
useDirectives(Directives)
@@ -708,6 +708,22 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst
}
}
@Nested
@TestMetadata("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime")
@TestDataPath("$PROJECT_ROOT")
public class NoRuntime {
@Test
public void testAllFilesPresentInNoRuntime() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("integerLiteralCall.kt")
public void testIntegerLiteralCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime/integerLiteralCall.kt");
}
}
@Nested
@TestMetadata("analysis/low-level-api-fir/testdata/lazyResolve/properties")
@TestDataPath("$PROJECT_ROOT")
@@ -708,6 +708,22 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou
}
}
@Nested
@TestMetadata("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime")
@TestDataPath("$PROJECT_ROOT")
public class NoRuntime {
@Test
public void testAllFilesPresentInNoRuntime() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("integerLiteralCall.kt")
public void testIntegerLiteralCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/lazyResolve/noRuntime/integerLiteralCall.kt");
}
}
@Nested
@TestMetadata("analysis/low-level-api-fir/testdata/lazyResolve/properties")
@TestDataPath("$PROJECT_ROOT")
@@ -43,9 +43,7 @@ class FirIntegerConstantOperatorScope(
scopeSession,
FakeOverrideTypeCalculator.DoNothing,
requiredMembersPhase = FirResolvePhase.STATUS,
) ?: errorWithAttachment("Scope for ${baseType::class.java} not found") {
withConeTypeEntry("type", baseType)
}
) ?: Empty
}
private val mappedFunctions = mutableMapOf<Name, FirNamedFunctionSymbol>()