[FIR] Remove FirNamedArgumentExpressions during completion

They are mostly necessary for argument mapping during resolution.
To support a couple checkers, we transform named args for varargs
into "fake" spread expressions.

Other than that, named arguments aren't needed for anything and often
lead to bugs where we forget to unwrap them for something, so it's
better to get rid of them.

#KT-66124
This commit is contained in:
Kirill Rakhman
2024-03-01 16:00:11 +01:00
committed by Space Team
parent 03fc0fd381
commit 8443daf78d
54 changed files with 249 additions and 117 deletions
@@ -53,5 +53,5 @@ FILE: annotationOnDeclarationWithDifferentArguments.kt
public get(): R|kotlin/Int|
public final const val constString: R|kotlin/String| = String()
public get(): R|kotlin/String|
@R|MyAnnotation|(intValue = Int(10), stringValue = R|/constString|, enumValue = Q|SomeEnum|.R|/SomeEnum.A|, kClasses = <implicitArrayOf>(<getClass>(Q|kotlin/String|), <getClass>(R|/constString|)), annotation = R|/MyOtherAnnotation.MyOtherAnnotation|(intValue = R|/constInt|, stringValue = String(hello))) public final fun foo(): R|kotlin/Unit| {
@R|MyAnnotation|(intValue = Int(10), stringValue = R|/constString|, enumValue = Q|SomeEnum|.R|/SomeEnum.A|, kClasses = <implicitArrayOf>(<getClass>(Q|kotlin/String|), <getClass>(R|/constString|)), annotation = R|/MyOtherAnnotation.MyOtherAnnotation|(R|/constInt|, String(hello))) public final fun foo(): R|kotlin/Unit| {
}
@@ -9,15 +9,15 @@ FILE: default.kt
R|/foo|(Int(1))
R|/foo|(Int(1), Double(2.0))
R|/foo|(Int(1), Double(2.0), Boolean(true))
R|/foo|(Int(1), third = Boolean(true))
R|/foo|(Int(1), Boolean(true))
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|()
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(Int(0), Double(0.0), Boolean(false), String())
R|/bar|(Int(1), third = Boolean(true))
R|/bar|(Int(1), Boolean(true))
R|/bar|(Int(1), Double(2.0), Boolean(true))
R|/bar|(Int(1), Double(2.0), Boolean(true), String(my))
R|/bar<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /bar>#|(Int(1), Boolean(true))
R|/baz|(Int(1))
R|/baz|(Int(1), vararg(String(my), String(yours)))
R|/baz|(Int(1), z = Boolean(true))
R|/baz|(Int(1), Boolean(true))
R|/baz<Inapplicable(INAPPLICABLE): /baz>#|(Int(0), String(), Boolean(false))
}
@@ -24,6 +24,6 @@ FILE: defaultFromOverrides.kt
R|<local>/a|.R|/A.foo|(Int(1))
R|<local>/a|.R|/A.bar<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /A.bar>#|()
R|<local>/a|.R|/A.bar<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /A.bar>#|(String())
R|<local>/a|.R|/A.bar|(y = Int(1))
R|<local>/a|.R|/A.bar|(Int(1))
R|<local>/a|.R|/A.bar|(String(), Int(2))
}
@@ -22,7 +22,7 @@ FILE: lambda.kt
^@foo Unit
}
)
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(f = foo@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(foo@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
^@foo Unit
}
, <L> = foo@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
@@ -33,7 +33,7 @@ FILE: lambda.kt
^@bar Unit
}
)
R|/bar|(x = Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
R|/bar|(Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
^@bar Unit
}
)
@@ -41,7 +41,7 @@ FILE: lambda.kt
^@bar Unit
}
)
R|/bar|(x = Int(1), f = bar@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
R|/bar|(Int(1), bar@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
^@bar Unit
}
)
@@ -53,7 +53,7 @@ FILE: lambda.kt
^@bar Unit
}
)
R|/baz|(other = Boolean(false), f = baz@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
R|/baz|(Boolean(false), baz@fun <anonymous>(): R|kotlin/Unit| <inline=NoInline> {
^@baz Unit
}
)
@@ -69,7 +69,7 @@ FILE: lambda.kt
^@baz Unit
}
)
R|/baz<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /baz>#|(other = Boolean(false), <L> = baz@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
R|/baz<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /baz>#|(Boolean(false), <L> = baz@fun <anonymous>(): R|kotlin/Unit| <inline=Unknown> {
^@baz Unit
}
)
@@ -8,7 +8,7 @@ FILE: namedArrayInAnnotation.kt
public get(): R|kotlin/Array<out kotlin/String>|
}
@R|Ann|(strings = vararg(strings = <implicitArrayOf>(String(hello)))) public final class A : R|kotlin/Any| {
@R|Ann|(strings = vararg(*<implicitArrayOf>(String(hello)))) public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
@@ -2,5 +2,5 @@ FILE: noParameterForName.kt
public final fun foo(x: R|kotlin/Int|): R|kotlin/Unit| {
}
public final fun bar(): R|kotlin/Unit| {
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(y = Int(1))
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(Int(1))
}
@@ -3,15 +3,15 @@ FILE: simple.kt
}
public final fun test(): R|kotlin/Unit| {
R|/foo|(Int(1), Double(2.0), Boolean(true), String())
R|/foo|(Int(1), Double(2.0), Boolean(true), fourth = String(!))
R|/foo|(Int(1), Double(2.0), fourth = String(???), third = Boolean(false))
R|/foo|(Int(1), second = Double(3.14), third = Boolean(false), fourth = String(!?))
R|/foo|(third = Boolean(false), second = Double(2.71), fourth = String(?!), first = Int(0))
R|/foo|(Int(1), Double(2.0), Boolean(true), String(!))
R|/foo|(Int(1), Double(2.0), String(???), Boolean(false))
R|/foo|(Int(1), Double(3.14), Boolean(false), String(!?))
R|/foo|(Boolean(false), Double(2.71), String(?!), Int(0))
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|()
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(Double(0.0), Boolean(false), Int(0), String())
R|/foo|(Int(1), Double(2.0), third = Boolean(true), String())
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(second = Double(0.0), first = Int(0), fourth = String())
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(first = Double(0.0), second = Int(0), third = String(), fourth = Boolean(false))
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(first = Int(0), second = Double(0.0), third = Boolean(false), fourth = String(), first = Int(1))
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(Int(0), Double(0.0), Boolean(false), foth = String())
R|/foo|(Int(1), Double(2.0), Boolean(true), String())
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(Double(0.0), Int(0), String())
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(Double(0.0), Int(0), String(), Boolean(false))
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(Int(0), Double(0.0), Boolean(false), String(), Int(1))
R|/foo<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /foo>#|(Int(0), Double(0.0), Boolean(false), String())
}
@@ -10,8 +10,8 @@ FILE: vararg.kt
R|/foo|(Int(1), vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(String())
R|/foo<Inapplicable(INAPPLICABLE): /foo>#|(Int(1), Int(2))
R|/bar|(Int(1), z = Boolean(true), vararg(y = *R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
R|/bar<Inapplicable(INAPPLICABLE): /bar>#|(Int(0), z = Boolean(false), y = String(), y = String(other))
R|/bar|(Int(1), Boolean(true), vararg(*R|kotlin/arrayOf|<R|kotlin/String|>(vararg(String(my), String(yours)))))
R|/bar<Inapplicable(INAPPLICABLE): /bar>#|(Int(0), Boolean(false), *String(), String(other))
R|/bar<Inapplicable(INAPPLICABLE_ARGUMENTS_MAPPING_ERROR): /bar>#|(Int(0), String(), Boolean(true))
R|/bar<Inapplicable(INAPPLICABLE): /bar>#|(Int(0), z = Boolean(false), y = String(), y = String(other), y = String(yet other))
R|/bar<Inapplicable(INAPPLICABLE): /bar>#|(Int(0), Boolean(false), *String(), String(other), String(yet other))
}
@@ -7,7 +7,7 @@ FILE: kt37056.kt
}
) }
Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|())
Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
}
public final class Case1 : R|kotlin/Any| {
private constructor(a: R|A|): R|Case1| {
@@ -31,7 +31,7 @@ FILE: kt37056.kt
}
public final fun case2(a: R|A|): R|kotlin/Unit| {
Q|Case2|.R|/Case2.Companion.invoke|(R|<local>/a|)
Q|Case2|.R|/Case2.Companion.invoke|(a = R|<local>/a|)
Q|Case2|.R|/Case2.Companion.invoke|(R|<local>/a|)
}
public final class Case2 : R|kotlin/Any| {
public constructor(): R|Case2| {
@@ -311,7 +311,7 @@ digraph lambdas_kt {
}
104 [label="Postponed exit from lambda"];
105 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
106 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
106 [label="Jump: ^test_4 R|/getInt|(getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
^test_4 Int(1)
}
)"];
@@ -35,7 +35,7 @@ FILE: lambdas.kt
)
}
public final fun test_4(): R|kotlin/Int| {
^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
^test_4 R|/getInt|(getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
^test_4 Int(1)
}
)
@@ -13,7 +13,7 @@ FILE: companionObjectCall.kt
}
) }
Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|())
Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|())
}
public final class Case1 : R|kotlin/Any| {
private constructor(a: R|kotlin/String|): R|Case1| {
@@ -37,7 +37,7 @@ FILE: companionObjectCall.kt
}
public final fun case2(a: R|A|): R|kotlin/Unit| {
Q|Case2|.R|/Case2.Companion.invoke|(R|<local>/a|)
Q|Case2|.R|/Case2.Companion.invoke|(a = R|<local>/a|)
Q|Case2|.R|/Case2.Companion.invoke|(R|<local>/a|)
}
public final class Case2 : R|kotlin/Any| {
public constructor(): R|Case2| {
@@ -58,7 +58,7 @@ FILE: companionObjectCall.kt
}
public final fun case3(a: R|A|): R|kotlin/Unit| {
Q|Case3.Companion|.R|/Case3.Companion.invoke|(R|<local>/a|)
Q|Case3.Companion|.R|/Case3.Companion.invoke|(parameterA = R|<local>/a|)
Q|Case3.Companion|.R|/Case3.Companion.invoke|(R|<local>/a|)
}
public final class Case3 : R|kotlin/Any| {
public constructor(): R|Case3| {
+2 -2
View File
@@ -18,8 +18,8 @@ FILE: copy.kt
}
public final fun test(some: R|Some|): R|kotlin/Unit| {
lval other: R|Some| = R|<local>/some|.R|/Some.copy|(y = String(123))
lval another: R|Some| = R|<local>/some|.R|/Some.copy|(x = Int(123))
lval other: R|Some| = R|<local>/some|.R|/Some.copy|(String(123))
lval another: R|Some| = R|<local>/some|.R|/Some.copy|(Int(123))
lval same: R|Some| = R|<local>/some|.R|/Some.copy|()
lval different: R|Some| = R|<local>/some|.R|/Some.copy|(Int(456), String(456))
}
@@ -17,7 +17,7 @@ FILE: nestedAnnotationConstExprArguments.kt
public get(): R|InnerAnnotation|
}
@R|OuterAnnotation|(inner = R|/InnerAnnotation.InnerAnnotation|(text = String(x).R|kotlin/String.plus|(String(x)))) public final class Payload : R|kotlin/Any| {
@R|OuterAnnotation|(inner = R|/InnerAnnotation.InnerAnnotation|(String(x).R|kotlin/String.plus|(String(x)))) public final class Payload : R|kotlin/Any| {
public constructor(): R|Payload| {
super<R|kotlin/Any|>()
}
@@ -29,7 +29,7 @@ FILE: nestedAnnotationConstExprArguments.kt
}
}
@R|OuterAnnotation|(inner = R|/InnerAnnotation.InnerAnnotation|(text = String(x))) public final class Payload3 : R|kotlin/Any| {
@R|OuterAnnotation|(inner = R|/InnerAnnotation.InnerAnnotation|(String(x))) public final class Payload3 : R|kotlin/Any| {
public constructor(): R|Payload3| {
super<R|kotlin/Any|>()
}