Hi all! I am writing a Kotlin plugin code, and at ...
# compiler
j
Hi all! I am writing a Kotlin plugin code, and at some point I would like to get all candidates descriptors of a (incomplete) function call. The code below works for calls that have only one possible candidate, but not for calls with multiple candidates/overloads :
Copy code
val context: BindingContext = ...
val callExpression: KtCallExpression = ...
val call = callExpression.getCall(context)
val resolvedDescriptor = call?.getResolvedCall(context)?.candidateDescriptor

if (resolvedDescriptor == null) {
  // TODO: Find a list of candidate descriptors.
}
For example, the following code:
Copy code
fun hello(s: String) { ... }
fun helloWithOverload(s: String) { ... }
fun helloWithOverload(i: Int) { ... }

fun main() {
  hello("foo") // will be correctly resolved
  hello() // will be correctly resolved as there is only one possible call
  helloWithOverload("foo") // will be correctly resolved as the call is complete
  helloWithOverload() // won't be resolved as the call is incomplete and there are multiple candidates
}
My question: what methods can I use to find those candidates ? Thanks a lot ­čÖé
r
You can look at this file and maybe trace back depending at which point you are resolving