FIR: fix use-site file in supertypes resolution
manifested in the IC tests by a seemingly redundant lookup, although theoretically may lead to more severe issues. Also fixes lookup recording ignoring logic, since the old one may break with the new us-site file calculation. #KT-55195 fixed
This commit is contained in:
committed by
Space Team
parent
dcbcc8b684
commit
62f2a09d70
+4
-3
@@ -24,9 +24,10 @@ class IncrementalPassThroughLookupTrackerComponent(
|
||||
private val sourceToFilePathsCache = ConcurrentHashMap<KtSourceElement, String>()
|
||||
|
||||
override fun recordLookup(name: Name, inScopes: List<String>, source: KtSourceElement?, fileSource: KtSourceElement?) {
|
||||
assert(fileSource != null || source is KtPsiSourceElement) // finding file for a source only possible for PSI, here it means
|
||||
// that we allow null for file source only for PSI-only "sources", currently - java ones
|
||||
val definedSource = fileSource ?: source ?: throw AssertionError("Cannot record lookup for \"$name\" without a source")
|
||||
// finding file for a source only possible for PSI, here it means
|
||||
// that we allow null for file source only for PSI-only "sources", currently - java ones, ignoring the other cases
|
||||
// TODO: although there are valid use cases for missing fileSource, the ignore may hide some possible bugs; consider stricter implementation
|
||||
val definedSource = fileSource ?: (source as? KtPsiSourceElement) ?: return
|
||||
val path = sourceToFilePathsCache.getOrPut(definedSource) {
|
||||
sourceToFilePath(definedSource) ?:
|
||||
// TODO: the lookup by non-file source mostly doesn't work for the LT, so we cannot afford null file sources here
|
||||
|
||||
+5
-2
@@ -348,8 +348,11 @@ open class FirSupertypeResolverVisitor(
|
||||
|
||||
val transformer = FirSpecificTypeResolverTransformer(session, supertypeSupplier = supertypeComputationSession.supertypesSupplier)
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
val resolvedTypesRefs = transformer.withFile(useSiteFile) {
|
||||
val newUseSiteFile =
|
||||
if (classLikeDeclaration.isLocalClassOrAnonymousObject()) @OptIn(PrivateForInline::class) useSiteFile
|
||||
else session.firProvider.getFirClassifierContainerFileIfAny(classLikeDeclaration.symbol)
|
||||
|
||||
val resolvedTypesRefs = transformer.withFile(newUseSiteFile) {
|
||||
resolveSuperTypeRefs(
|
||||
transformer,
|
||||
ScopeClassDeclaration(scopes, classDeclarationsStack, containerDeclaration = classLikeDeclaration),
|
||||
|
||||
@@ -3,7 +3,7 @@ private class C {
|
||||
companion object
|
||||
}
|
||||
|
||||
private typealias TA = <!INVISIBLE_REFERENCE!>C<!>
|
||||
private typealias TA = C
|
||||
|
||||
private val test1: <!INVISIBLE_REFERENCE!>C<!> = <!INVISIBLE_REFERENCE!>C<!>()
|
||||
private val test1co: <!INVISIBLE_REFERENCE!>C.Companion<!> = <!INITIALIZER_TYPE_MISMATCH, INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>C<!>
|
||||
|
||||
@@ -57,19 +57,19 @@ fun main(args: Array<String>) {
|
||||
testClass<AbstractIncrementalK2JvmJpsTest>(
|
||||
init = incrementalJvmTestData(
|
||||
TargetBackend.JVM_IR,
|
||||
excludePattern = "(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"
|
||||
excludePattern = "(^.*Expect.*)"
|
||||
)
|
||||
)
|
||||
testClass<AbstractIncrementalK2LightTreeJvmJpsTest>(
|
||||
init = incrementalJvmTestData(
|
||||
TargetBackend.JVM_IR,
|
||||
excludePattern = "(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"
|
||||
excludePattern = "(^.*Expect.*)"
|
||||
)
|
||||
)
|
||||
testClass<AbstractIncrementalK2FirICLightTreeJvmJpsTest>(
|
||||
init = incrementalJvmTestData(
|
||||
TargetBackend.JVM_IR,
|
||||
excludePattern = "(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"
|
||||
excludePattern = "(^.*Expect.*)"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+12
-2
@@ -64,7 +64,7 @@ public class IncrementalK2FirICLightTreeJvmJpsTestGenerated extends AbstractIncr
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPureKotlin() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotations")
|
||||
@@ -117,6 +117,11 @@ public class IncrementalK2FirICLightTreeJvmJpsTestGenerated extends AbstractIncr
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/classSignatureUnchanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("companionConstantChanged")
|
||||
public void testCompanionConstantChanged() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/companionConstantChanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("compilationErrorThenFixedOtherPackage")
|
||||
public void testCompilationErrorThenFixedOtherPackage() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedOtherPackage/");
|
||||
@@ -692,7 +697,7 @@ public class IncrementalK2FirICLightTreeJvmJpsTestGenerated extends AbstractIncr
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInClassHierarchyAffected() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationFlagRemoved")
|
||||
@@ -725,6 +730,11 @@ public class IncrementalK2FirICLightTreeJvmJpsTestGenerated extends AbstractIncr
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate/");
|
||||
}
|
||||
|
||||
@TestMetadata("classMovedIntoOtherClass")
|
||||
public void testClassMovedIntoOtherClass() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("classRemoved")
|
||||
public void testClassRemoved() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classRemoved/");
|
||||
|
||||
Generated
+12
-2
@@ -64,7 +64,7 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPureKotlin() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotations")
|
||||
@@ -117,6 +117,11 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/classSignatureUnchanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("companionConstantChanged")
|
||||
public void testCompanionConstantChanged() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/companionConstantChanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("compilationErrorThenFixedOtherPackage")
|
||||
public void testCompilationErrorThenFixedOtherPackage() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedOtherPackage/");
|
||||
@@ -692,7 +697,7 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInClassHierarchyAffected() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationFlagRemoved")
|
||||
@@ -725,6 +730,11 @@ public class IncrementalK2JvmJpsTestGenerated extends AbstractIncrementalK2JvmJp
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate/");
|
||||
}
|
||||
|
||||
@TestMetadata("classMovedIntoOtherClass")
|
||||
public void testClassMovedIntoOtherClass() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("classRemoved")
|
||||
public void testClassRemoved() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classRemoved/");
|
||||
|
||||
+12
-2
@@ -64,7 +64,7 @@ public class IncrementalK2LightTreeJvmJpsTestGenerated extends AbstractIncrement
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPureKotlin() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/pureKotlin"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotations")
|
||||
@@ -117,6 +117,11 @@ public class IncrementalK2LightTreeJvmJpsTestGenerated extends AbstractIncrement
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/classSignatureUnchanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("companionConstantChanged")
|
||||
public void testCompanionConstantChanged() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/companionConstantChanged/");
|
||||
}
|
||||
|
||||
@TestMetadata("compilationErrorThenFixedOtherPackage")
|
||||
public void testCompilationErrorThenFixedOtherPackage() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/pureKotlin/compilationErrorThenFixedOtherPackage/");
|
||||
@@ -692,7 +697,7 @@ public class IncrementalK2LightTreeJvmJpsTestGenerated extends AbstractIncrement
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInClassHierarchyAffected() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)|(^classMovedIntoOtherClass)|(^companionConstantChanged)"), TargetBackend.JVM_IR, false);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("jps/jps-plugin/testData/incremental/classHierarchyAffected"), Pattern.compile("^([^\\.]+)$"), Pattern.compile("(^.*Expect.*)"), TargetBackend.JVM_IR, false);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationFlagRemoved")
|
||||
@@ -725,6 +730,11 @@ public class IncrementalK2LightTreeJvmJpsTestGenerated extends AbstractIncrement
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classBecamePrivate/");
|
||||
}
|
||||
|
||||
@TestMetadata("classMovedIntoOtherClass")
|
||||
public void testClassMovedIntoOtherClass() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass/");
|
||||
}
|
||||
|
||||
@TestMetadata("classRemoved")
|
||||
public void testClassRemoved() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/classHierarchyAffected/classRemoved/");
|
||||
|
||||
Reference in New Issue
Block a user