FIR IDE: fix finding fir in container which have conflicting duplicate by name

This commit is contained in:
Ilya Kirillov
2021-01-06 18:20:15 +01:00
parent 601d5cbff8
commit c97c4fa99c
4 changed files with 9 additions and 2 deletions
@@ -1,3 +1,5 @@
// FIR_COMPARISON
class A {
fun f() : A
}
@@ -1,3 +1,5 @@
// FIR_COMPARISON
object A {
fun f() : S
}
@@ -91,8 +91,12 @@ private fun KtDeclaration.findSourceNonLocalFirDeclarationByProvider(
firFile.declarations
}
val original = originalDeclaration
/*
It is possible that we will not be able to find needed declaration here when the code is invalid,
e.g, we have two conflicting declarations with the same name and we are searching in the wrong one
*/
declarations?.firstOrNull { it.psi == this || it.psi == original }
?: error("Cannot find corresponding fir for\n${this.getElementTextInContext()}")
}
this is KtConstructor<*> -> {
val containingClass = containingClassOrObject
@@ -1,4 +1,3 @@
// IGNORE_FIR
package test
class A