mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] prefer empty vararg over implicit null (IDEA-178858)
This commit is contained in:
+5
@@ -69,6 +69,11 @@ public class GrDefaultMethodComparator extends GrMethodComparator {
|
||||
|
||||
PsiParameter[] params1 = method1.getParameterList().getParameters();
|
||||
PsiParameter[] params2 = method2.getParameterList().getParameters();
|
||||
|
||||
if (argTypes != null && argTypes.length == 0) {
|
||||
if (params2.length == 1 && params2[0].getType() instanceof PsiArrayType) return true;
|
||||
}
|
||||
|
||||
if (argTypes == null && params1.length != params2.length) return false;
|
||||
|
||||
if (params1.length < params2.length) {
|
||||
|
||||
+16
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.resolve
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PropertyUtil
|
||||
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression
|
||||
@@ -2292,4 +2293,19 @@ new SomeClass().si<caret>ze()
|
||||
''', GrMethodImpl
|
||||
|
||||
}
|
||||
|
||||
void 'test prefer varargs in no-arg call'() {
|
||||
def file = fixture.configureByText('_.groovy', '''\
|
||||
class A {
|
||||
A(String... a) { println "varargs" }
|
||||
A(A a) { println "single" }
|
||||
}
|
||||
|
||||
new A()
|
||||
''') as GroovyFile
|
||||
def expression = file.statements.last() as GrNewExpression
|
||||
def resolved = expression.resolveMethod()
|
||||
assert resolved instanceof GrMethod
|
||||
assert resolved.isVarArgs()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user