Fix argument mapping for lambda arguments and default arguments

Maybe for other elements ValueArgument itself used as SourceElement
This commit is contained in:
Stanislav Erokhin
2021-05-10 12:09:02 +02:00
parent 335c5a03b6
commit 080a832605
11 changed files with 4 additions and 13 deletions
@@ -167,15 +167,17 @@ internal class FirWrapperResolvedCall(val firSimpleWrapperCall: FirSimpleWrapper
val firArguments = firCall.withFir { it.argumentMapping } ?: context.implementationPostponed()
val argumentExpression = valueArgument.getArgumentExpression() ?: context.implementationPostponed()
fun FirExpression.isMyArgument() = realPsi === valueArgument || realPsi === argumentExpression
var targetFirParameter: FirValueParameter? = null
outer@ for ((firExpression, firValueParameter) in firArguments.entries) {
if (firExpression is FirVarargArgumentsExpression) {
for (subExpression in firExpression.arguments)
if (subExpression.realPsi === argumentExpression) {
if (subExpression.isMyArgument()) {
targetFirParameter = firValueParameter
break@outer
}
} else if (firExpression.realPsi === argumentExpression) {
} else if (firExpression.isMyArgument()) {
targetFirParameter = firValueParameter
break@outer
}
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(fn: () -> Boolean) : Boolean = true
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun <T> doSomething(a: T) {}
fun test() {
@@ -1,4 +1,3 @@
// IGNORE_FE10_BINDING_BY_FIR
fun <T> doSomething(a: T) {}
fun test() {
@@ -1,7 +1,5 @@
// IS_APPLICABLE: false
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(a: Int=1, b: Int=2) : Boolean = true
@@ -1,6 +1,5 @@
// IS_APPLICABLE: false
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
// IGNORE_FE10_BINDING_BY_FIR
fun test() {
class Test{
operator fun contains(vararg b: Int, c: Int = 0): Boolean = true