Fix incorrect handling of mixed named/positional arguments

^KT-40404 Fixed
This commit is contained in:
Denis Zharkov
2020-07-23 16:12:34 +03:00
parent d083297366
commit dc6efa5a61
9 changed files with 63 additions and 7 deletions
@@ -0,0 +1,18 @@
// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
fun foo(a: String, b: String) {}
fun reformat(
str: String,
normalizeCase: String = "default",
upperCaseFirstLetter: Boolean = true,
divideByCamelHumps: Boolean = false,
wordSeparator: Char = ' '
) {}
fun main() {
<!INAPPLICABLE_CANDIDATE!>foo<!>(b = "first", a = "a", "second") // prints "a, second"
<!INAPPLICABLE_CANDIDATE!>reformat<!>(normalizeCase = "first",str = "","second",false,true, 's' )
}
@@ -0,0 +1,19 @@
// !LANGUAGE: +NewInference +MixedNamedArgumentsInTheirOwnPosition
// !DIAGNOSTICS: -UNUSED_PARAMETER
// SKIP_TXT
fun foo(a: String, b: String) {}
fun reformat(
str: String,
normalizeCase: String = "default",
upperCaseFirstLetter: Boolean = true,
divideByCamelHumps: Boolean = false,
wordSeparator: Char = ' '
) {}
fun main() {
foo(b = "first", a = "a", <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"second"<!>) // prints "a, second"
reformat(normalizeCase = "first",str = "",<!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"second"<!>,<!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>false<!>,<!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>true<!>, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>'s'<!> )
}
@@ -26,5 +26,5 @@ public @interface A {
@A fun test8() {}
@A(x = Any::class, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>*arrayOf("5", "6")<!>, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"7"<!>, y = 3) fun test9() {}
@A(x = Any::class, value = ["5", "6"], <!NI;POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, NI;TYPE_MISMATCH, OI;MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"7"<!>, y = 3) fun test10() {}
@A(x = Any::class, value = ["5", "6"], <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"7"<!>, y = 3) fun test10() {}
@A(x = Any::class, value = ["5", "6", "7"], y = 3) fun test11() {}
@@ -1,7 +1,7 @@
package
@A(value = {"1", "2", "3"}) public fun test1(): kotlin.Unit
@A(value = {"5", "6"}, x = "7", y = 3) public fun test10(): kotlin.Unit
@A(value = {"5", "6"}, x = kotlin.Any::class, y = 3) public fun test10(): kotlin.Unit
@A(value = {"5", "6", "7"}, x = kotlin.Any::class, y = 3) public fun test11(): kotlin.Unit
@A(value = {"4"}) public fun test2(): kotlin.Unit
@A(value = {{"5", "6"}, "7"}) public fun test3(): kotlin.Unit