K2: prefer base class sources for JVM mapped functions
This commit is a follow-up to 3cb9396b20
"K2: prefer derived class sources for callable copies (e.g. fake overrides)"
#KT-64044 Fixed
This commit is contained in:
committed by
Space Team
parent
c80854eb7c
commit
f5453690a6
+6
@@ -118,6 +118,12 @@ public class Fe10IdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exte
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/ClassReferenceInImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CollectionStream.kt")
|
||||
public void testCollectionStream() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/CollectionStream.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CompanionObjectWithName1.kt")
|
||||
public void testCompanionObjectWithName1() throws Exception {
|
||||
|
||||
+6
@@ -118,6 +118,12 @@ public class FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated ex
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/ClassReferenceInImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CollectionStream.kt")
|
||||
public void testCollectionStream() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/CollectionStream.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CompanionObjectWithName1.kt")
|
||||
public void testCompanionObjectWithName1() throws Exception {
|
||||
|
||||
+6
@@ -118,6 +118,12 @@ public class FirIdeNormalAnalysisLibrarySourceModuleReferenceResolveTestGenerate
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/ClassReferenceInImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CollectionStream.kt")
|
||||
public void testCollectionStream() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/CollectionStream.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CompanionObjectWithName1.kt")
|
||||
public void testCompanionObjectWithName1() throws Exception {
|
||||
|
||||
+6
@@ -118,6 +118,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exten
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/ClassReferenceInImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CollectionStream.kt")
|
||||
public void testCollectionStream() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/CollectionStream.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CompanionObjectWithName1.kt")
|
||||
public void testCompanionObjectWithName1() throws Exception {
|
||||
|
||||
+7
-2
@@ -78,8 +78,9 @@ abstract class AbstractReferenceResolveTest : AbstractAnalysisApiBasedTest() {
|
||||
val resolvedTo = analyzeReferenceElement(ktReferences.first().element, mainModule) {
|
||||
val symbols = ktReferences.flatMap { it.resolveToSymbols() }
|
||||
checkReferenceResultForValidity(ktReferences, mainModule, testServices, symbols)
|
||||
renderResolvedTo(symbols, renderingOptions) { getAdditionalSymbolInfo(it) }
|
||||
}
|
||||
val renderPsiClassName = Directives.RENDER_PSI_CLASS_NAME in mainModule.directives
|
||||
renderResolvedTo(symbols, renderPsiClassName, renderingOptions) { getAdditionalSymbolInfo(it) }
|
||||
}
|
||||
|
||||
if (Directives.UNRESOLVED_REFERENCE in mainModule.directives) {
|
||||
return
|
||||
@@ -119,6 +120,10 @@ abstract class AbstractReferenceResolveTest : AbstractAnalysisApiBasedTest() {
|
||||
val UNRESOLVED_REFERENCE by directive(
|
||||
"Reference should be unresolved",
|
||||
)
|
||||
|
||||
val RENDER_PSI_CLASS_NAME by directive(
|
||||
"Render also PSI class name for resolved reference"
|
||||
)
|
||||
}
|
||||
|
||||
private val renderingOptions = KtDeclarationRendererForDebug.WITH_QUALIFIED_NAMES.with {
|
||||
|
||||
+9
-2
@@ -17,16 +17,18 @@ import org.jetbrains.kotlin.types.Variance
|
||||
object TestReferenceResolveResultRenderer {
|
||||
fun KtAnalysisSession.renderResolvedTo(
|
||||
symbols: List<KtSymbol>,
|
||||
renderPsiClassName: Boolean = false,
|
||||
renderer: KtDeclarationRenderer = KtDeclarationRendererForDebug.WITH_QUALIFIED_NAMES,
|
||||
additionalInfo: KtAnalysisSession.(KtSymbol) -> String? = { null }
|
||||
) =
|
||||
symbols.map { renderResolveResult(it, renderer, additionalInfo) }
|
||||
symbols.map { renderResolveResult(it, renderPsiClassName, renderer, additionalInfo) }
|
||||
.sorted()
|
||||
.withIndex()
|
||||
.joinToString(separator = "\n") { "${it.index}: ${it.value}" }
|
||||
|
||||
private fun KtAnalysisSession.renderResolveResult(
|
||||
symbol: KtSymbol,
|
||||
renderPsiClassName: Boolean,
|
||||
renderer: KtDeclarationRenderer,
|
||||
additionalInfo: KtAnalysisSession.(KtSymbol) -> String?
|
||||
): String {
|
||||
@@ -35,7 +37,12 @@ object TestReferenceResolveResultRenderer {
|
||||
append("(in $fqName) ")
|
||||
}
|
||||
when (symbol) {
|
||||
is KtDeclarationSymbol -> append(symbol.render(renderer))
|
||||
is KtDeclarationSymbol -> {
|
||||
append(symbol.render(renderer))
|
||||
if (renderPsiClassName) {
|
||||
append(" (psi: ${symbol.psi?.let { it::class.simpleName }})")
|
||||
}
|
||||
}
|
||||
is KtPackageSymbol -> append("package ${symbol.fqName}")
|
||||
is KtReceiverParameterSymbol -> {
|
||||
append("extension receiver with type ")
|
||||
|
||||
+6
@@ -118,6 +118,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceResolveTestGenerate
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/ClassReferenceInImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CollectionStream.kt")
|
||||
public void testCollectionStream() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/CollectionStream.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("CompanionObjectWithName1.kt")
|
||||
public void testCompanionObjectWithName1() throws Exception {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// ISSUE: KT-64044
|
||||
// IGNORE_FE10
|
||||
// (stream call is unresolved for some reason)
|
||||
// FULL_JDK
|
||||
// RENDER_PSI_CLASS_NAME
|
||||
|
||||
fun f(collection: Collection<String>) {
|
||||
collection.strea<caret>m()
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in kotlin.collections.Collection) fun stream(): java.util.stream.Stream<E> (psi: ClsMethodImpl)
|
||||
Reference in New Issue
Block a user