[FIR IDE] Add a special type of KtCall for generic type qualifiers

^KTIJ-21672 Fixed
This commit is contained in:
Roman Golyshev
2022-06-14 16:15:02 +04:00
committed by teamcity
parent fe06070d23
commit 581ae5fcb7
10 changed files with 129 additions and 3 deletions
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.*
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtExpression
/**
@@ -114,6 +115,33 @@ public class KtInapplicableCallCandidateInfo(
*/
public sealed class KtCall : KtLifetimeOwner
/**
* A special call for type qualifiers with generic parameters, which, from the PSI perspective, are [KtCallExpression]-s.
*
* Examples:
*
* ```
* fun test() {
* Collection<*>::isEmpty
*
* kotlin.List<Int>::size
* }
* ```
*
* Both `Collection<*>` and `List<Int>` are [KtCallExpression]-s, so we need to be able to successfully resolve them to something
* sensible - that's why we need [KtGenericTypeQualifier].
*/
public class KtGenericTypeQualifier(
override val token: KtLifetimeToken,
private val _qualifier: KtExpression,
) : KtCall() {
/**
* The full qualifier - either a [KtCallExpression] or a [org.jetbrains.kotlin.psi.KtDotQualifiedExpression].
*/
public val qualifier: KtExpression get() = withValidityAssertion { _qualifier }
}
/**
* A callable symbol partially applied with receivers and type arguments. Essentially, this is a call that misses some information. For
* properties, the missing information is the type of access (read, write, or compound access) to this property. For functions, the missing
@@ -0,0 +1,9 @@
package test
class Test<T> {
fun foo() {}
}
class Bar
val bar = <expr>Test<Bar></expr>::foo
@@ -0,0 +1,3 @@
KtSuccessCallInfo:
call = KtGenericTypeQualifier:
qualifier = Test<Bar>
@@ -0,0 +1,9 @@
package test
class Test<T> {
fun foo() {}
}
class Bar
val bar = test.<expr>Test<Bar></expr>::foo
@@ -0,0 +1,3 @@
KtSuccessCallInfo:
call = KtGenericTypeQualifier:
qualifier = test.Test<Bar>