"Constructor has non-null self reference parameter": don't report for vararg parameter
#KT-36160 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f3f88cae7a
commit
3ebad2acec
+1
@@ -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()
|
||||
}
|
||||
+5
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user