Delay UNUSED_PARAMETER on main parameter until 1.4 (part of KT-26999)

This commit is contained in:
Mikhail Glukhikh
2018-10-30 17:28:32 +03:00
parent 388aecb249
commit ad44118605
22 changed files with 46 additions and 40 deletions
@@ -671,7 +671,7 @@ class ControlFlowInformationProvider private constructor(
val mainFunctionDetector = MainFunctionDetector(trace.bindingContext, languageVersionSettings)
val isMain = owner is KtNamedFunction && mainFunctionDetector.isMain(owner)
val functionName = functionDescriptor.name
if (isMain && !languageVersionSettings.supportsFeature(LanguageFeature.ExtendedMainConvention)
if (isMain && !languageVersionSettings.supportsFeature(LanguageFeature.WarningOnMainUnusedParameter)
|| functionDescriptor.isOverridableOrOverrides
|| owner.hasModifier(KtTokens.OVERRIDE_KEYWORD)
|| OperatorNameConventions.GET_VALUE == functionName
@@ -1,5 +0,0 @@
// !LANGUAGE: -ExtendedMainConvention
fun main(args: Array<String>) {
}
@@ -1,3 +1,5 @@
// !LANGUAGE: +WarningOnMainUnusedParameter
fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {
}
@@ -0,0 +1,5 @@
// !LANGUAGE: -WarningOnMainUnusedParameter
fun main(args: Array<String>) {
}
@@ -1,4 +1,4 @@
// KT-9733 No error shown for 2 "main" functions in the same file
<!CONFLICTING_OVERLOADS!>fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>)<!> {}
<!CONFLICTING_OVERLOADS!>fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>)<!> {}
<!CONFLICTING_OVERLOADS!>fun main(args: Array<String>)<!> {}
<!CONFLICTING_OVERLOADS!>fun main(args: Array<String>)<!> {}
@@ -1,7 +1,7 @@
// FILE: a.kt
<!CONFLICTING_OVERLOADS!>fun main()<!> {}
suspend fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
suspend fun main(args: Array<String>) {}
// FILE: b.kt
<!CONFLICTING_OVERLOADS!>fun main()<!> {}
@@ -1,8 +1,8 @@
// FILE: a.kt
fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
fun main(args: Array<String>) {}
// FILE: b.kt
fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
fun main(args: Array<String>) {}
// FILE: c.kt
fun foo() { <!OVERLOAD_RESOLUTION_AMBIGUITY!>main<!>(arrayOf("a", "b")) }
@@ -3608,14 +3608,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/localObjectInConstructor.kt");
}
@TestMetadata("mainWith12.kt")
public void testMainWith12() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWith12.kt");
@TestMetadata("mainWithWarningOnUnusedParam.kt")
public void testMainWithWarningOnUnusedParam() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWithWarningOnUnusedParam.kt");
}
@TestMetadata("mainWith13.kt")
public void testMainWith13() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWith13.kt");
@TestMetadata("mainWithoutWarningOnUnusedParam.kt")
public void testMainWithoutWarningOnUnusedParam() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWithoutWarningOnUnusedParam.kt");
}
@TestMetadata("nestedTryFinally.kt")
@@ -3608,14 +3608,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/localObjectInConstructor.kt");
}
@TestMetadata("mainWith12.kt")
public void testMainWith12() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWith12.kt");
@TestMetadata("mainWithWarningOnUnusedParam.kt")
public void testMainWithWarningOnUnusedParam() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWithWarningOnUnusedParam.kt");
}
@TestMetadata("mainWith13.kt")
public void testMainWith13() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWith13.kt");
@TestMetadata("mainWithoutWarningOnUnusedParam.kt")
public void testMainWithoutWarningOnUnusedParam() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/mainWithoutWarningOnUnusedParam.kt");
}
@TestMetadata("nestedTryFinally.kt")
@@ -91,6 +91,7 @@ enum class LanguageFeature(
DslMarkerOnFunctionTypeReceiver(KOTLIN_1_4, kind = BUG_FIX),
RestrictReturnStatementTarget(KOTLIN_1_4, kind = BUG_FIX),
NoConstantValueAttributeForNonConstVals(KOTLIN_1_4, kind = BUG_FIX),
WarningOnMainUnusedParameter(KOTLIN_1_4),
ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX),
// Temporarily disabled, see KT-27084/KT-22379
@@ -77,6 +77,7 @@ fun getDefaultLanguageLevel(
fun String?.toLanguageVersion(): LanguageVersion = when {
this == null -> VersionView.RELEASED_VERSION
startsWith("1.4") -> LanguageVersion.KOTLIN_1_4
startsWith("1.3") -> LanguageVersion.KOTLIN_1_3
startsWith("1.2") -> LanguageVersion.KOTLIN_1_2
startsWith("1.1") -> LanguageVersion.KOTLIN_1_1
+1 -1
View File
@@ -50,7 +50,7 @@ fun Int.foo() = this
fun Any?.equals1(<warning>other</warning> : Any?) : Boolean = true
fun Any.equals2(<warning>other</warning> : Any?) : Boolean = true
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
System.out.print(1)
@@ -1,3 +1,5 @@
// LANGUAGE_VERSION: 1.4
fun main(<warning descr="[UNUSED_PARAMETER] Parameter 'args' is never used">args</warning>: Array<String>) {
}
@@ -1,4 +1,4 @@
// LANGUAGE_VERSION: 1.2
// LANGUAGE_VERSION: 1.3
fun main(args: Array<String>) {
+1 -1
View File
@@ -2,7 +2,7 @@ package test2
<info descr="null">enum</info> class En { A, B, С }
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
val en2: Any? = En.A
if (en2 is En) {
when (<info descr="Smart cast to test2.En">en2</info>) {
+1 -1
View File
@@ -1,4 +1,4 @@
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
String.class<EOLError descr="Name expected"></EOLError>
}
+1 -1
View File
@@ -38,7 +38,7 @@ fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
return lhs
}
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
System.out.println("24 game")
val numbers = ArrayList<Int>(4)
val rnd = Random();
+1 -1
View File
@@ -4,7 +4,7 @@ fun parse(<warning>cmd</warning>: String): Command? { return null }
fun Any.<warning>equals</warning>(other : Any?) : Boolean = this === other
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
val command = parse("")
if (command == null) <warning>1</warning> // error on this line, but must be OK
}
+1 -1
View File
@@ -1,6 +1,6 @@
fun Any.<warning>equals</warning>(<warning>other</warning> : Any?) : Boolean = true
fun main(<warning>args</warning>: Array<String>) {
fun main(args: Array<String>) {
val command : Any = 1
@@ -156,6 +156,16 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
runTest("idea/testData/checker/LocalObjects.kt");
}
@TestMetadata("MainWithWarningOnUnusedParam.kt")
public void testMainWithWarningOnUnusedParam() throws Exception {
runTest("idea/testData/checker/MainWithWarningOnUnusedParam.kt");
}
@TestMetadata("MainWithoutWarningOnUnusedParam.kt")
public void testMainWithoutWarningOnUnusedParam() throws Exception {
runTest("idea/testData/checker/MainWithoutWarningOnUnusedParam.kt");
}
@TestMetadata("MultipleBounds.kt")
public void testMultipleBounds() throws Exception {
runTest("idea/testData/checker/MultipleBounds.kt");
@@ -321,16 +331,6 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
runTest("idea/testData/checker/Unused.kt");
}
@TestMetadata("UnusedParameterInEntry12.kt")
public void testUnusedParameterInEntry12() throws Exception {
runTest("idea/testData/checker/UnusedParameterInEntry12.kt");
}
@TestMetadata("UnusedParameterInEntry13.kt")
public void testUnusedParameterInEntry13() throws Exception {
runTest("idea/testData/checker/UnusedParameterInEntry13.kt");
}
@TestMetadata("Variance.kt")
public void testVariance() throws Exception {
runTest("idea/testData/checker/Variance.kt");