Analysis API: Get argument mapping from candidate and type parameters

from candidate symbol.
This commit is contained in:
Mark Punzalan
2022-01-31 17:58:28 +00:00
committed by Ilya Kirillov
parent 0ed802bca4
commit ace826c570
19 changed files with 887 additions and 14 deletions
@@ -0,0 +1,76 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions can be called with the arguments supplied:
public fun function(b: Boolean): Unit defined in root package in file ambiguous.kt
public fun function(a: Char): Unit defined in root package in file ambiguous.kt
public fun function(c: String): Unit defined in root package in file ambiguous.kt>
@@ -0,0 +1,7 @@
fun function(a: Char) {}
fun function(b: Boolean) {}
fun function(c: String) {}
fun call() {
<expr>function(1)</expr>
}
@@ -0,0 +1,73 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions are applicable: [/function, /function, /function]>
@@ -0,0 +1,91 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = TypeVariable(T)
symbol = t: T,
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = TypeVariable(T)
symbol = t: T)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = u
receiverType = null
returnType = TypeVariable(U)
symbol = u: U,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = u
receiverType = null
returnType = TypeVariable(U)
symbol = u: U)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = v
receiverType = null
returnType = TypeVariable(V)
symbol = v: V,
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = v
receiverType = null
returnType = TypeVariable(V)
symbol = v: V)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions can be called with the arguments supplied:
public fun <T> function(t: TypeVariable(T), a: Char): Unit defined in root package in file ambiguousWithExplicitTypeParameters.kt
public fun <U> function(u: TypeVariable(U), b: Boolean): Unit defined in root package in file ambiguousWithExplicitTypeParameters.kt
public fun <V> function(v: TypeVariable(V), c: String): Unit defined in root package in file ambiguousWithExplicitTypeParameters.kt>
@@ -0,0 +1,7 @@
fun <T> function(t: T, a: Char) {}
fun <U> function(u: U, b: Boolean) {}
fun <V> function(v: V, c: String) {}
fun call() {
<expr>function<Int>(1)</expr>
}
@@ -0,0 +1,88 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = kotlin.Int
symbol = t: T,
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = kotlin.Int
symbol = t: T)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = u
receiverType = null
returnType = kotlin.Int
symbol = u: U,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = u
receiverType = null
returnType = kotlin.Int
symbol = u: U)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = v
receiverType = null
returnType = kotlin.Int
symbol = v: V,
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = v
receiverType = null
returnType = kotlin.Int
symbol = v: V)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions are applicable: [/function, /function, /function]>
@@ -0,0 +1,91 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = TypeVariable(T)
symbol = t: T,
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = TypeVariable(T)
symbol = t: T)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = u
receiverType = null
returnType = TypeVariable(U)
symbol = u: U,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = u
receiverType = null
returnType = TypeVariable(U)
symbol = u: U)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = v
receiverType = null
returnType = TypeVariable(V)
symbol = v: V,
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = v
receiverType = null
returnType = TypeVariable(V)
symbol = v: V)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions can be called with the arguments supplied:
public fun <T> function(t: TypeVariable(T), a: Char): Unit defined in root package in file ambiguousWithInferredTypeParameters.kt
public fun <U> function(u: TypeVariable(U), b: Boolean): Unit defined in root package in file ambiguousWithInferredTypeParameters.kt
public fun <V> function(v: TypeVariable(V), c: String): Unit defined in root package in file ambiguousWithInferredTypeParameters.kt>
@@ -0,0 +1,7 @@
fun <T> function(t: T, a: Char) {}
fun <U> function(u: U, b: Boolean) {}
fun <V> function(v: V, c: String) {}
fun call() {
<expr>function(1)</expr>
}
@@ -0,0 +1,88 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
symbol = t: T,
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
symbol = t: T)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = u
receiverType = null
returnType = U
symbol = u: U,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = u
receiverType = null
returnType = U
symbol = u: U)
},
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = v
receiverType = null
returnType = V
symbol = v: V,
KtVariableLikeSignature:
name = c
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = v
receiverType = null
returnType = V
symbol = v: V)
}
]
diagnostic = ERROR<NONE_APPLICABLE: None of the following functions are applicable: [/function, /function, /function]>
@@ -0,0 +1,7 @@
fun function(a: Char) {}
fun function(b: Boolean) {}
fun function(c: String) {}
fun call() {
<expr>function(1)</expr>
}
@@ -0,0 +1,77 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char)
}
]
diagnostic = ERROR<ARGUMENT_TYPE_MISMATCH: Argument type mismatch: actual type is kotlin/Int but kotlin/Char was expected>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean)
}
]
diagnostic = ERROR<ARGUMENT_TYPE_MISMATCH: Argument type mismatch: actual type is kotlin/Int but kotlin/Boolean was expected>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String)
}
]
diagnostic = ERROR<ARGUMENT_TYPE_MISMATCH: Argument type mismatch: actual type is kotlin/Int but kotlin/String was expected>
@@ -0,0 +1,7 @@
fun <T> function(t: T, a: Char) {}
fun <U> function(u: U, b: Boolean) {}
fun <V> function(v: V, c: String) {}
fun call() {
<expr>function<Int>(1)</expr>
}
@@ -0,0 +1,89 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = t: T,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = t: T)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'a'>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = u: U,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = u: U)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'b'>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = v: V,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = v: V)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'c'>
@@ -0,0 +1,7 @@
fun <T> function(t: T, a: Char) {}
fun <U> function(u: U, b: Boolean) {}
fun <V> function(v: V, c: String) {}
fun call() {
<expr>function(1)</expr>
}
@@ -0,0 +1,89 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(t: T, a: kotlin.Char): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = T
symbol = t: T,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Char
symbol = a: kotlin.Char
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = T
symbol = t: T)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'a'>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(u: U, b: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = U
symbol = u: U,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = b: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = U
symbol = u: U)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'b'>
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(v: V, c: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
receiverType = null
returnType = V
symbol = v: V,
KtVariableLikeSignature:
receiverType = null
returnType = kotlin.String
symbol = c: kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
receiverType = null
returnType = V
symbol = v: V)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'c'>