Don't suggest "convert to array literal" for *arrayOf #KT-21726 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f68d639c63
commit
d719d06020
+4
-1
@@ -44,7 +44,10 @@ class ReplaceArrayOfWithLiteralInspection : AbstractKotlinInspection() {
|
||||
|
||||
val parent = expression.parent
|
||||
when (parent) {
|
||||
is KtValueArgument -> parent.parent.parent as? KtAnnotationEntry ?: return
|
||||
is KtValueArgument -> {
|
||||
if (parent.parent.parent !is KtAnnotationEntry) return
|
||||
if (parent.getSpreadElement() != null && !parent.isNamed()) return
|
||||
}
|
||||
is KtParameter -> {
|
||||
val constructor = parent.parent.parent as? KtPrimaryConstructor ?: return
|
||||
val containingClass = constructor.getContainingClassOrObject()
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// PROBLEM: none
|
||||
|
||||
annotation class Some(vararg val strings: String)
|
||||
|
||||
@Some(*<caret>arrayOf("alpha", "beta", "omega"))
|
||||
class My
|
||||
@@ -2324,6 +2324,12 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("unnamedVararg.kt")
|
||||
public void testUnnamedVararg() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamedVararg.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("vararg.kt")
|
||||
public void testVararg() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt");
|
||||
|
||||
Reference in New Issue
Block a user