ReplaceArrayOfWithLiteralInspection: Remove unnecessary parentheses

#KT-21878 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-05-07 18:44:34 +03:00
committed by Alexey Sedunov
parent c95ed9fd20
commit 8271e85dbb
4 changed files with 29 additions and 0 deletions
@@ -449,6 +449,8 @@ public class KtPsiUtil {
return false;
}
if (parentElement instanceof KtCollectionLiteralExpression) return false;
if (innerExpression instanceof KtIfExpression) {
if (parentElement instanceof KtQualifiedExpression) return true;
@@ -0,0 +1,11 @@
// LANGUAGE_VERSION: 1.2
import kotlin.reflect.KClass
class Foo
class Bar
annotation class Ann(val values: Array<KClass<*>>)
@Ann(values = <caret>arrayOf(Foo::class, Bar::class))
class Test
@@ -0,0 +1,11 @@
// LANGUAGE_VERSION: 1.2
import kotlin.reflect.KClass
class Foo
class Bar
annotation class Ann(val values: Array<KClass<*>>)
@Ann(values = [Foo::class, Bar::class])
class Test
@@ -3755,6 +3755,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt");
}
@TestMetadata("kclass.kt")
public void testKclass() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/kclass.kt");
}
@TestMetadata("noAnnotation.kt")
public void testNoAnnotation() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noAnnotation.kt");