mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
[java] skip diamond inference for constructor calls of static nested classes
EA-246216 - T: JavaMethodsConflictResolver.resolveConflict GitOrigin-RevId: 5fc2f7118bf68a1d0b9f80bfcbbbfa768fc6bea8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c378f327ff
commit
5a29d515fc
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi;
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
@@ -109,7 +95,15 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
|
||||
private PsiNewExpression getNewExpression() {
|
||||
PsiElement typeElementWithDiamondTypeArgument = myTypeElement.getParent();
|
||||
return PsiTreeUtil.getParentOfType(typeElementWithDiamondTypeArgument, PsiNewExpression.class, true, PsiTypeElement.class);
|
||||
PsiNewExpression newExpression =
|
||||
PsiTreeUtil.getParentOfType(typeElementWithDiamondTypeArgument, PsiNewExpression.class, true, PsiTypeElement.class, PsiStatement.class);
|
||||
if (newExpression != null) {
|
||||
PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference();
|
||||
if (classReference != null && classReference.getParameterList() == typeElementWithDiamondTypeArgument) {
|
||||
return newExpression;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class R<T> {
|
||||
static class O {
|
||||
public O(<error descr="'R.this' cannot be referenced from a static context">T</error> t) {
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
test(new R<>.O<error descr="'O(java.lang.Object)' in 'R.O' cannot be applied to '()'">()</error>);
|
||||
}
|
||||
|
||||
private static void test(R.O o) {}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
@@ -101,6 +101,9 @@ public class Diamond8HighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testDiamondsUncheckedWarning() { doTest();}
|
||||
public void testWrongNumberOfArguments() { doTest();}
|
||||
public void testNestedClassArgConstructor() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
|
||||
Reference in New Issue
Block a user