diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java index dbf454207cca..d85fb72894d7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java @@ -403,6 +403,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig if (varargParam != null && pi >= parameters.length) return false; PsiType exprType = RefactoringUtil.getTypeByExpression(expression); if (exprType == null) return false; + exprType = GenericsUtil.getVariableTypeByExpressionType(exprType); JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(expression.getProject()); String name = suggestUniqueParameterName(codeStyleManager, expression, exprType, existingNames); final ParameterInfoImpl newParameterInfo = new ParameterInfoImpl(-1, name, exprType, expression.getText().replace('\n', ' ')); diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java index 4646aea635b3..163055f442fa 100644 --- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java @@ -351,6 +351,9 @@ public class GenericsUtil { @Nullable public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) { if (type == null) return null; + if (type instanceof PsiDisjunctionType) { + type = ((PsiDisjunctionType)type).getLeastUpperBound(); + } if (type instanceof PsiCapturedWildcardType) { type = ((PsiCapturedWildcardType)type).getWildcard(); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index 9c9525aef859..d53bb2e26820 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -389,7 +389,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { } else { //unbounded - substituted = PsiWildcardType.createExtends(manager, substitutedBoundType); + substituted = substitutedBoundType instanceof PsiCapturedWildcardType ? ((PsiCapturedWildcardType)substitutedBoundType).getWildcard() : PsiWildcardType.createExtends(manager, substitutedBoundType); } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardFromUnboundCaptureWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardFromUnboundCaptureWildcard.java new file mode 100644 index 000000000000..0abec87dc335 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/CaptureWildcardFromUnboundCaptureWildcard.java @@ -0,0 +1,9 @@ +class Test & Runnable> {} + +interface Supplier { + K get(); +} + +interface Getter extends Supplier { + public S get(); +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106985.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106985.java new file mode 100644 index 000000000000..b11bfa46632c --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA106985.java @@ -0,0 +1,15 @@ + +import java.util.Map; + +class Test { + + public static void main(String[] args) { + Map map = make(); + } + + + public static Map make() { + return null; + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncompatibleBoundsFromAssignment.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncompatibleBoundsFromAssignment.java new file mode 100644 index 000000000000..d5b8b03050d5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncompatibleBoundsFromAssignment.java @@ -0,0 +1,15 @@ +import java.util.Map; + +class Test { + + public static void main(String[] args) { + Map b = newMapTrie(); + Map> c = newMapTrie(); + Map>> d = newMapTrie(); + Map>>> e = newMapTrie(); + } + + public static > T newMapTrie() { + return null; + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/afterDisjunctionType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/afterDisjunctionType.java new file mode 100644 index 000000000000..7835cfb40ae9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/afterDisjunctionType.java @@ -0,0 +1,15 @@ +// "Add 'Exception' as 1st parameter to method 'f'" "true" +import java.io.FileInputStream; +import java.io.IOException; + +class Test { + public void createFileInputStream() { + try { + new FileInputStream("test"); + } catch (IOException |NullPointerException e) { + f(e); + } + } + + public void f(Exception e) { } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/beforeDisjunctionType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/beforeDisjunctionType.java new file mode 100644 index 000000000000..ab28d7484f4d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeMethodSignatureFromUsage8/beforeDisjunctionType.java @@ -0,0 +1,15 @@ +// "Add 'Exception' as 1st parameter to method 'f'" "true" +import java.io.FileInputStream; +import java.io.IOException; + +class Test { + public void createFileInputStream() { + try { + new FileInputStream("test"); + } catch (IOException |NullPointerException e) { + f(e); + } + } + + public void f() { } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 09225b64bc1d..0a93d8f7f193 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -372,6 +372,8 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIDEA126633() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testIDEA124363() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testIDEA78402() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testIDEA106985() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } + public void testCaptureWildcardFromUnboundCaptureWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testSuperCaptureSubstitutionWhenTypeParameterHasUpperBounds() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } public void testParameterBoundsWithCapturedWildcard() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); } //jdk should propagate LL 1.4 but actually it provides LL 1.7?! diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index e6e4534b6560..9ec2d29b71e3 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -236,6 +236,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testIncompatibleBoundsFromAssignment() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java index 1b56554333b0..712df26e356f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewLambdaHighlightingTest.java @@ -22,6 +22,8 @@ import com.intellij.idea.Bombed; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.testFramework.IdeaTestUtil; +import junit.framework.Test; +import junit.framework.TestSuite; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -107,7 +109,6 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } - @Bombed(day = 30, month = Calendar.SEPTEMBER) public void testIDEA124983() throws Exception { doTest(); } @@ -145,4 +146,12 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase { protected Sdk getProjectJDK() { return IdeaTestUtil.getMockJdk18(); } +/* + public static Test suite() { + final TestSuite suite = new TestSuite(); + for (int i = 0; i < 100; i++) { + suite.addTestSuite(NewLambdaHighlightingTest.class); + } + return suite; + }*/ } diff --git a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java index bbffc7c98ba4..02ddd0b64608 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/github/DownloadUtil.java @@ -1,5 +1,6 @@ package com.intellij.platform.templates.github; +import com.intellij.openapi.application.ex.ApplicationInfoEx; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -19,7 +20,6 @@ import java.net.HttpURLConnection; import java.net.URLConnection; import java.util.Locale; import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; /** * @author Sergey Simonchik @@ -176,6 +176,7 @@ public class DownloadUtil { URLConnection urlConnection = HttpConfigurable.getInstance().openConnection(location); HttpURLConnection httpURLConnection = ObjectUtils.tryCast(urlConnection, HttpURLConnection.class); try { + urlConnection.setRequestProperty("User-Agent", ApplicationInfoEx.getInstanceEx().getFullApplicationName()); urlConnection.connect(); InputStream in = urlConnection.getInputStream(); int contentLength = urlConnection.getContentLength(); diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 9956959f0e22..852f00cb7a68 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -418,7 +418,7 @@ public class PathManager { private static String getAbsolutePath(String path) { path = FileUtil.expandUserHome(path); - return FileUtil.toCanonicalPath(new File(FileUtil.toCanonicalPath(path)).getAbsolutePath()); + return FileUtil.toCanonicalPath(new File(path).getAbsolutePath()); } private static String trimPathQuotes(String path){ diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/Ambiguity.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/Ambiguity.java index 6df5c30ae69a..e8be7a9d0b0c 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/Ambiguity.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/lambda2anonymous/Ambiguity.java @@ -2,14 +2,14 @@ interface I1 { void m(); } -interface I2 { - X m(); +interface I2 { + void m(); } class Ambiguity1 { static void m(I1 i1) {} - static void m(I2 i2) {} + static void m(I2 i2) {} { m(()->{throw new AssertionError();});