mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java] Don't suggest generating broken overload constructors
In implicit and anonymous classes, constructors can't be declared. #IDEA-359731 Fixed GitOrigin-RevId: 76e978d04052dffd955bfac6c1016fa707201b29
This commit is contained in:
committed by
intellij-monorepo-bot
parent
941408d4c8
commit
690f1167ff
@@ -50,6 +50,9 @@ public final class DefineParamsDefaultValueAction extends PsiBasedModCommandActi
|
||||
if (containingClass == null || (containingClass.isInterface() && !PsiUtil.isAvailable(JavaFeature.EXTENSION_METHODS, method))) {
|
||||
return null;
|
||||
}
|
||||
if ((containingClass instanceof PsiImplicitClass || containingClass instanceof PsiAnonymousClass) && method.isConstructor()) {
|
||||
return null; // constructors can't be declared here, code is broken so don't suggest generating more broken code
|
||||
}
|
||||
if (containingClass.isAnnotationType()) {
|
||||
// Method with parameters in annotation is a compilation error; there's no sense to create overload
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Generate overloaded constructor with default parameter values" "false"
|
||||
class Bar {
|
||||
interface Foo {
|
||||
void bar();
|
||||
}
|
||||
|
||||
public void bar() {
|
||||
Foo foo = new Foo() {
|
||||
Foo(String str<caret>) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bar() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// "Generate overloaded constructor with default parameter values" "false"
|
||||
Foo(String str<caret>)
|
||||
Reference in New Issue
Block a user