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

Original commit: c97c4fa99cc06411e1cbf6531b76171e336c8011

GitOrigin-RevId: 4ab313b05d9d63ad7f8b41fc5d05d35d1246c7a4
This commit is contained in:
Ilya Kirillov
2021-06-30 09:04:23 +00:00
committed by intellij-monorepo-bot
parent 6310e740c3
commit a60e40aa1d
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