mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't erase method invocation type iff unchecked conversion was required during additional constraints processing (IDEA-163503)
This commit is contained in:
+8
@@ -86,6 +86,7 @@ public class InferenceSession {
|
||||
private List<String> myErrorMessages;
|
||||
|
||||
private boolean myErased;
|
||||
private boolean myCheckApplicabilityPhase = true;
|
||||
|
||||
public final InferenceIncorporationPhase myIncorporationPhase = new InferenceIncorporationPhase(this);
|
||||
|
||||
@@ -374,6 +375,7 @@ public class InferenceSession {
|
||||
return;
|
||||
}
|
||||
|
||||
myCheckApplicabilityPhase = false;
|
||||
if (properties != null && !properties.isApplicabilityCheck()) {
|
||||
final PsiMethod method = properties.getMethod();
|
||||
if (parent instanceof PsiCallExpression && PsiPolyExpressionUtil.isMethodCallPolyExpression((PsiExpression)parent, method)) {
|
||||
@@ -1669,6 +1671,12 @@ public class InferenceSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setErasedDuringApplicabilityCheck() {
|
||||
if (myCheckApplicabilityPhase) {
|
||||
myErased = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setErased() {
|
||||
myErased = true;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -61,7 +61,7 @@ public class TypeCompatibilityConstraint implements ConstraintFormula {
|
||||
}
|
||||
|
||||
if (isUncheckedConversion(myT, myS)) {
|
||||
session.setErased();
|
||||
session.setErasedDuringApplicabilityCheck();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
private static List<Object> test(List<List> list) {
|
||||
return list.stream().flatMap(List::stream).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -18,16 +18,13 @@ package com.intellij.codeInsight.daemon.lambda;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection;
|
||||
import com.intellij.idea.Bombed;
|
||||
import com.intellij.lang.annotation.HighlightSeverity;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -486,6 +483,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testErasureOfReturnTypeIffUncheckedConversionWasNecessaryDuringApplicabilityCheckOnly() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user