mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
method type params should be excluded from signature when overriding from raw type (IDEA-67585;IDEA-67582)
This commit is contained in:
@@ -263,7 +263,7 @@ public class OverrideImplementUtil {
|
||||
}
|
||||
if (results.isEmpty()) {
|
||||
PsiMethod method1 = GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);
|
||||
|
||||
|
||||
PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
|
||||
PsiMethod result = (PsiMethod)factory.createClass("Dummy").add(method1);
|
||||
if (result instanceof PsiAnnotationMethod) {
|
||||
@@ -304,6 +304,20 @@ public class OverrideImplementUtil {
|
||||
}
|
||||
}
|
||||
|
||||
//method type params are not allowed when overriding from raw type
|
||||
final PsiTypeParameterList list = result.getTypeParameterList();
|
||||
if (list != null) {
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
for (PsiClassType classType : aClass.getSuperTypes()) {
|
||||
if (InheritanceUtil.isInheritorOrSelf(PsiUtil.resolveClassInType(classType), containingClass, true) && classType.isRaw()) {
|
||||
list.replace(JavaPsiFacade.getElementFactory(aClass.getProject()).createTypeParameterList());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
annotateOnOverrideImplement(result, aClass, method, insertOverrideIfPossible);
|
||||
|
||||
if (CodeStyleSettingsManager.getSettings(aClass.getProject()).REPEAT_SYNCHRONIZED && method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
interface A<T> {
|
||||
<S> void foo();
|
||||
}
|
||||
|
||||
class B implements A
|
||||
{
|
||||
public void foo() {
|
||||
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
abstract class A<T> {
|
||||
abstract <S extends T> void foo(S s);
|
||||
}
|
||||
|
||||
class B<S> extends A<Throwable>{ // Implement methods
|
||||
|
||||
@Override
|
||||
<S extends Throwable> void foo(S s) {
|
||||
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
interface A<T> {
|
||||
<S> void foo();
|
||||
}
|
||||
|
||||
class B implements A
|
||||
{
|
||||
<caret>
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
abstract class A<T> {
|
||||
abstract <S extends T> void foo(S s);
|
||||
}
|
||||
|
||||
class B<S> extends A<Throwable>{ // Implement methods
|
||||
<caret>
|
||||
}
|
||||
@@ -37,6 +37,8 @@ public class OverrideImplementTest extends LightCodeInsightTestCase {
|
||||
public void testWildcard() throws Exception { doTest(false); }
|
||||
public void testTypeParam() throws Exception { doTest(false); }
|
||||
public void testInterfaceAndAbstractClass() throws Exception { doTest(false); }
|
||||
public void testRawSuper() throws Exception { doTest(false); }
|
||||
public void testSubstituteBoundInMethodTypeParam() throws Exception { doTest(false); }
|
||||
|
||||
public void testLongFinalParameterList() throws Exception {
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
|
||||
|
||||
Reference in New Issue
Block a user