K2 IC: fix lookup recording for a "red" companion object
#KT-63665 fixed
This commit is contained in:
committed by
Space Team
parent
6dfcc927f4
commit
ed820d6b57
@@ -19,10 +19,13 @@ abstract class FirLookupTrackerComponent : FirSessionComponent {
|
||||
}
|
||||
|
||||
fun FirLookupTrackerComponent.recordCallLookup(callInfo: AbstractCallInfo, inType: ConeKotlinType) {
|
||||
if (inType.classId?.isLocal == true) return
|
||||
val classId = inType.classId
|
||||
if (classId?.isLocal == true) return
|
||||
val scopes = SmartList(inType.renderForDebugging().replace('/', '.'))
|
||||
if (inType.classId?.shortClassName?.asString() == "Companion") {
|
||||
scopes.add(inType.classId!!.outerClassId!!.asString().replace('/', '.'))
|
||||
if (classId != null && classId.shortClassName.asString() == "Companion") {
|
||||
classId.outerClassId?.asString()?.replace('/', '.')?.let {
|
||||
scopes.add(it)
|
||||
}
|
||||
}
|
||||
recordLookup(callInfo.name, scopes, callInfo.callSite.source, callInfo.containingFile.source)
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.incremental;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class IncrementalK2JvmCompilerRunnerTestCustom extends AbstractIncrementalK2JvmCompilerRunnerTest {
|
||||
@TestMetadata("jps/jps-plugin/testData/incremental/custom")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Custom extends AbstractIncrementalK2JvmCompilerRunnerTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("companionWithSyntaxError")
|
||||
public void testCompanionWithSyntaxError() throws Exception {
|
||||
runTest("jps/jps-plugin/testData/incremental/custom/companionWithSyntaxError/");
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
================ Step #1 =================
|
||||
|
||||
After chunkBuildStarted. Marked as dirty by Kotlin:
|
||||
src/main.kt
|
||||
Cleaning output files:
|
||||
out/production/module/A$Companion.class
|
||||
out/production/module/A.class
|
||||
out/production/module/META-INF/module.kotlin_module
|
||||
End of files
|
||||
Compiling files:
|
||||
src/main.kt
|
||||
End of files
|
||||
Exit code: ABORT
|
||||
------------------------------------------
|
||||
COMPILATION FAILED
|
||||
|
||||
================ Step #2 =================
|
||||
|
||||
Compiling files:
|
||||
src/main.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
@@ -0,0 +1,7 @@
|
||||
class A() {
|
||||
|
||||
companion object {
|
||||
fun equals(): Boolean =
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A() {
|
||||
} // extra curly brace
|
||||
|
||||
companion object {
|
||||
fun equals(): Boolean =
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A() {
|
||||
|
||||
companion object {
|
||||
fun equals(): Boolean =
|
||||
TODO()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user