"Constructor has non-null self reference parameter": don't report for vararg parameter

#KT-36160 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-01-30 19:54:36 +09:00
committed by Mikhail Glukhikh
parent f3f88cae7a
commit 3ebad2acec
3 changed files with 12 additions and 0 deletions
@@ -37,6 +37,7 @@ class SelfReferenceConstructorParameterInspection : AbstractKotlinInspection() {
val containingClass = this.containingClass() ?: return null
val className = containingClass.name ?: return null
val parameter = this.parameters.firstOrNull { it.typeReference?.text == className } ?: return null
if (parameter.isVarArg) return null
val typeReference = parameter.typeReference ?: return null
val context = analyze(BodyResolveMode.PARTIAL)
@@ -0,0 +1,6 @@
// PROBLEM: none
class Foo(vararg children: Foo<caret>)
fun test() {
Foo()
}
@@ -11441,6 +11441,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
public void testNullable() throws Exception {
runTest("idea/testData/inspectionsLocal/selfReferenceConstructorParameter/nullable.kt");
}
@TestMetadata("vararg.kt")
public void testVararg() throws Exception {
runTest("idea/testData/inspectionsLocal/selfReferenceConstructorParameter/vararg.kt");
}
}
@TestMetadata("idea/testData/inspectionsLocal/setterBackingFieldAssignment")