mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
exact method refs most specific: void compatibility
This commit is contained in:
+3
-3
@@ -1106,15 +1106,15 @@ public class InferenceSession {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType;
|
||||
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType;
|
||||
final boolean sPrimitive = sReturnType instanceof PsiPrimitiveType && sReturnType != PsiType.VOID;
|
||||
final boolean tPrimitive = tReturnType instanceof PsiPrimitiveType && tReturnType != PsiType.VOID;
|
||||
|
||||
if (sPrimitive ^ tPrimitive) {
|
||||
final PsiMember member = ((PsiMethodReferenceExpression)arg).getPotentiallyApplicableMember();
|
||||
LOG.assertTrue(member != null);
|
||||
if (member instanceof PsiMethod) {
|
||||
final PsiType methodReturnType = ((PsiMethod)member).getReturnType();
|
||||
if (sPrimitive && methodReturnType instanceof PsiPrimitiveType ||
|
||||
if (sPrimitive && methodReturnType instanceof PsiPrimitiveType && methodReturnType != PsiType.VOID ||
|
||||
tPrimitive && methodReturnType instanceof PsiClassType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
class Test {
|
||||
|
||||
interface I { void i_bar(); }
|
||||
interface I1<T> { T i1_bar(); }
|
||||
|
||||
private void m(I i) {System.out.println(i);}
|
||||
private void <warning descr="Private method 'm(Test.I1<java.lang.String>)' is never used">m</warning>(I1<String> i1) {System.out.println(i1);}
|
||||
|
||||
void test() {
|
||||
m(Test::foo);
|
||||
}
|
||||
|
||||
public static int foo() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
|
||||
interface I { void i_bar(); }
|
||||
interface I1<T> { T i1_bar(); }
|
||||
|
||||
void m(I i) { System.out.println(i);}
|
||||
void m(I1<String> i1) { System.out.println(i1);}
|
||||
|
||||
void test() {
|
||||
m(Test1::foo);
|
||||
}
|
||||
|
||||
public static String foo() {return "";}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
|
||||
interface I { void i_bar(); }
|
||||
interface I1<T> { T i1_bar(); }
|
||||
|
||||
void m(I i) { System.out.println(i);}
|
||||
void m(I1<String> i1) { System.out.println(i1);}
|
||||
|
||||
void test() {
|
||||
m(Test2::foo);
|
||||
}
|
||||
|
||||
public static void foo() {}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls static final String BASE_PATH = "/codeInsight/daemonCodeAnalyzer/lambda/mostSpecific";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{
|
||||
new UnusedSymbolLocalInspection(),
|
||||
};
|
||||
}
|
||||
|
||||
public void testVoidConflict() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest(boolean warnings) {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_8, getModule(), getTestRootDisposable());
|
||||
doTestNewInference(BASE_PATH + "/" + getTestName(false) + ".java", warnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user