diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java index 8b0d965716bb..f382ecf5ea98 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java @@ -64,6 +64,9 @@ class ConstructorReferencesSearchHelper { @Override public Void compute() { constructorCanBeCalledImplicitly[0] = constructor.getParameterList().getParametersCount() == 0; + if (!constructorCanBeCalledImplicitly[0]) { + constructorCanBeCalledImplicitly[0] = hasDefaultConstructorWithVarargParameter(containingClass); + } isEnum[0] = containingClass.isEnum(); isUnder18[0] = PsiUtil.getLanguageLevel(containingClass).isAtLeast(LanguageLevel.JDK_1_8); return null; @@ -124,6 +127,17 @@ class ConstructorReferencesSearchHelper { return ClassInheritorsSearch.search(containingClass, searchScope, false).forEach(processor2); } + private static boolean hasDefaultConstructorWithVarargParameter(@NotNull PsiClass containingClass) { + final PsiMethod[] constructors = containingClass.getConstructors(); + for (PsiMethod ctr : constructors) { + final PsiParameter[] parameters = ctr.getParameterList().getParameters(); + if (parameters.length == 1 && parameters[0].isVarArgs()) { + return true; + } + } + return false; + } + private static boolean processEnumReferences(@NotNull final Processor processor, @NotNull final PsiMethod constructor, @NotNull final Project project, diff --git a/java/java-tests/testSrc/com/intellij/psi/search/FindFixtureBasedTest.kt b/java/java-tests/testSrc/com/intellij/psi/search/FindFixtureBasedTest.kt new file mode 100644 index 000000000000..0854777bfbf1 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/psi/search/FindFixtureBasedTest.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.search + +import com.intellij.psi.search.searches.MethodReferencesSearch +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase + +class FindFixtureBasedTest : LightCodeInsightFixtureTestCase() { + fun testDefaultConstructorWithVarargsParameters() { + val aClass = myFixture.addClass("public class Foo {public Foo(int... a) {}}") + myFixture.addClass("public class Bar extends Foo {}") + + val constructors = aClass.constructors + assertSize(1, constructors) + val references = MethodReferencesSearch.search(constructors[0]).findAll() + assertSize(1, references) + } +}