Don't report warning about changing execution order for varargs if it's inside an annotation
^KT-43110 Fixed
This commit is contained in:
+5
@@ -920,6 +920,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontReportWarningAboutChangingExecutionOrderForVararg.kt")
|
||||
public void testDontReportWarningAboutChangingExecutionOrderForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/dontReportWarningAboutChangingExecutionOrderForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionType.kt")
|
||||
public void testExtensionFunctionType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/extensionFunctionType.kt");
|
||||
|
||||
+3
@@ -12,12 +12,15 @@ import org.jetbrains.kotlin.psi.KtValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getParameterForArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.components.isVararg
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isAnnotationConstructor
|
||||
|
||||
object VarargWrongExecutionOrderChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val isCorrectExecutionOrderForVarargArgumentsAlreadyUsed =
|
||||
context.languageVersionSettings.getFeatureSupport(LanguageFeature.UseCorrectExecutionOrderForVarargArguments) == LanguageFeature.State.ENABLED
|
||||
|
||||
if (resolvedCall.candidateDescriptor.isAnnotationConstructor()) return
|
||||
|
||||
if (isCorrectExecutionOrderForVarargArgumentsAlreadyUsed) return
|
||||
|
||||
val valueArguments = resolvedCall.call.valueArguments
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno(vararg val x: String, val y: String)
|
||||
|
||||
@Anno(x = [["a", "b"], ["a", "b"]], y = "a")
|
||||
fun foo1() {}
|
||||
|
||||
@Anno(x = ["a", "b"], y = "a")
|
||||
fun foo2() {}
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>@Anno(x = arrayOf(arrayOf("a"), arrayOf("b")), y = "a")<!>
|
||||
fun foo3() {}
|
||||
|
||||
@Anno(x = arrayOf("a", "b"), y = "a")
|
||||
fun foo4() {}
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno1(val x: Array<in String>, val y: String)
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno2(vararg val x: String, val y: String)
|
||||
|
||||
@Anno1(x = ["", Anno2(x = [""], y = "")], y = "")
|
||||
fun foo5() {}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno(vararg val x: String, val y: String)
|
||||
|
||||
@Anno(x = [<!TYPE_MISMATCH, TYPE_MISMATCH!>["a", "b"]<!>, <!TYPE_MISMATCH, TYPE_MISMATCH!>["a", "b"]<!>], y = "a")
|
||||
fun foo1() {}
|
||||
|
||||
@Anno(x = ["a", "b"], y = "a")
|
||||
fun foo2() {}
|
||||
|
||||
@Anno(x = <!TYPE_MISMATCH, TYPE_MISMATCH!>arrayOf(arrayOf("a"), arrayOf("b"))<!>, y = "a")
|
||||
fun foo3() {}
|
||||
|
||||
@Anno(x = arrayOf("a", "b"), y = "a")
|
||||
fun foo4() {}
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno1(val x: Array<in String>, val y: String)
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Anno2(vararg val x: String, val y: String)
|
||||
|
||||
@Anno1(x = ["", Anno2(x = [""], y = "")], y = "")
|
||||
fun foo5() {}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package
|
||||
|
||||
@Anno(x = {{"a", "b"}, {"a", "b"}}, y = "a") public fun foo1(): kotlin.Unit
|
||||
@Anno(x = {"a", "b"}, y = "a") public fun foo2(): kotlin.Unit
|
||||
@Anno(x = {{"a"}, {"b"}}, y = "a") public fun foo3(): kotlin.Unit
|
||||
@Anno(x = {"a", "b"}, y = "a") public fun foo4(): kotlin.Unit
|
||||
@Anno1(x = {"", Anno2(x = {""}, y = "")}, y = "") public fun foo5(): kotlin.Unit
|
||||
|
||||
@kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ vararg x: kotlin.String /*kotlin.Array<out kotlin.String>*/, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Array<out kotlin.String>
|
||||
public final val y: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Anno1 : kotlin.Annotation {
|
||||
public constructor Anno1(/*0*/ x: kotlin.Array<in kotlin.String>, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Array<in kotlin.String>
|
||||
public final val y: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Anno2 : kotlin.Annotation {
|
||||
public constructor Anno2(/*0*/ vararg x: kotlin.String /*kotlin.Array<out kotlin.String>*/, /*1*/ y: kotlin.String)
|
||||
public final val x: kotlin.Array<out kotlin.String>
|
||||
public final val y: kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+3
-3
@@ -24,13 +24,13 @@ fun test_ann(s: String, arr: Array<String>) {
|
||||
foo()
|
||||
@Ann(*[""], x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = [""]<!>, x = 1)
|
||||
@Ann(s = [""], x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = *<!REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION!>[""]<!><!>, x = 1)
|
||||
@Ann(s = *<!REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION!>[""]<!>, x = 1)
|
||||
foo()
|
||||
|
||||
@Ann("", x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = <!ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR, NI;TYPE_MISMATCH!>""<!><!>, x = 1)
|
||||
@Ann(s = <!ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR, NI;TYPE_MISMATCH!>""<!>, x = 1)
|
||||
foo()
|
||||
}
|
||||
+3
-3
@@ -24,13 +24,13 @@ fun test_ann(s: String, arr: Array<String>) {
|
||||
foo()
|
||||
@Ann(*[""], x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = [""]<!>, x = 1)
|
||||
@Ann(s = [""], x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = *<!REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION!>[""]<!><!>, x = 1)
|
||||
@Ann(s = *<!REDUNDANT_SPREAD_OPERATOR_IN_NAMED_FORM_IN_ANNOTATION!>[""]<!>, x = 1)
|
||||
foo()
|
||||
|
||||
@Ann("", x = 1)
|
||||
foo()
|
||||
@Ann(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>s = <!ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR, NI;TYPE_MISMATCH!>""<!><!>, x = 1)
|
||||
@Ann(s = <!ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_ANNOTATION_ERROR, NI;TYPE_MISMATCH!>""<!>, x = 1)
|
||||
foo()
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ fun jTest1() {}
|
||||
@JavaAnn(value = ["value"])
|
||||
fun jTest2() {}
|
||||
|
||||
@JavaAnn(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>value = ["value"]<!>, path = ["path"])
|
||||
@JavaAnn(value = ["value"], path = ["path"])
|
||||
fun jTest3() {}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ fun jTest1() {}
|
||||
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>)
|
||||
fun jTest2() {}
|
||||
|
||||
@JavaAnn(<!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!><!>, path = ["path"])
|
||||
@JavaAnn(value = <!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, TYPE_MISMATCH!>["value"]<!>, path = ["path"])
|
||||
fun jTest3() {}
|
||||
|
||||
annotation class IntAnn(vararg val i: Int)
|
||||
|
||||
+2
-2
@@ -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, <!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>value = ["5", "6"]<!>, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>"7"<!>, y = 3) fun test10() {}
|
||||
@A(x = Any::class, <!NI;CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS!>value = ["5", "6", "7"]<!>, y = 3) fun test11() {}
|
||||
@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() {}
|
||||
|
||||
@@ -927,6 +927,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontReportWarningAboutChangingExecutionOrderForVararg.kt")
|
||||
public void testDontReportWarningAboutChangingExecutionOrderForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/dontReportWarningAboutChangingExecutionOrderForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionType.kt")
|
||||
public void testExtensionFunctionType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/extensionFunctionType.kt");
|
||||
|
||||
Generated
+5
@@ -922,6 +922,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/deprecatedRepeatable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("dontReportWarningAboutChangingExecutionOrderForVararg.kt")
|
||||
public void testDontReportWarningAboutChangingExecutionOrderForVararg() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/dontReportWarningAboutChangingExecutionOrderForVararg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionType.kt")
|
||||
public void testExtensionFunctionType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/extensionFunctionType.kt");
|
||||
|
||||
Reference in New Issue
Block a user