mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
inference: check substituted intersection type during resolution
This commit is contained in:
@@ -1246,7 +1246,10 @@ public class InferenceSession {
|
||||
if (type instanceof PsiIntersectionType) {
|
||||
String conflictingConjunctsMessage = ((PsiIntersectionType)type).getConflictingConjunctsMessage();
|
||||
if (conflictingConjunctsMessage == null) {
|
||||
if (findParameterizationOfTheSameGenericClass(var.getBounds(InferenceBound.UPPER), pair -> pair.first == null || pair.second == null || pair.first.equals(pair.second)) != null) {
|
||||
if (findParameterizationOfTheSameGenericClass(var.getBounds(InferenceBound.UPPER),
|
||||
pair -> pair.first == null || pair.second == null ||
|
||||
Comparing.equal(substituteNonProperBound(pair.first, substitutor),
|
||||
substituteNonProperBound(pair.second, substitutor))) != null) {
|
||||
//warn if upper bounds has same generic class with different type arguments
|
||||
conflictingConjunctsMessage = type.getPresentableText(false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class MyTest {
|
||||
public <T> void from(Page<T> elements) { }
|
||||
|
||||
public <T> void from(Collection<T> elements) { }
|
||||
|
||||
public void foo(final Stream<String> artifactStream) {
|
||||
from(artifactStream.collect(Collectors.toCollection(<error descr="Bad return type in method reference: cannot convert java.util.TreeSet<java.lang.String> to C">TreeSet<String>::new</error>)));
|
||||
}
|
||||
|
||||
interface Page<T> extends Iterable<T> {}
|
||||
}
|
||||
@@ -184,6 +184,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testPertinentToApplicabilityCheckForBlockLambda() { doTest(); }
|
||||
public void testCheckGlbConflictsAfterIntersectionTypeCreated() { doTest(); }
|
||||
public void testRestoreCapturedWildcardsInReturnTypesWhenNoAdditionalConstraintsDetected() { doTest(); }
|
||||
public void testIntersectionWithSameInterfaceButDifferentTypeArgument() { doTest(); }
|
||||
public void testVarargsMethodPreferred() { doTest(); }
|
||||
|
||||
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() {
|
||||
|
||||
Reference in New Issue
Block a user