fix exception on unboxing captured wildcard of numeric type

GitOrigin-RevId: 6fb5c3ed9b1225d4224c8c543221d12412718114
This commit is contained in:
Alexey Kudravtsev
2020-03-10 13:32:01 +00:00
committed by intellij-monorepo-bot
parent 29e3a57092
commit 295a9bc984
3 changed files with 15 additions and 3 deletions
@@ -1111,6 +1111,8 @@ public class TypeConversionUtil {
*/
@NotNull
public static PsiType binaryNumericPromotion(PsiType type1, PsiType type2) {
type1 = uncapture(type1);
type2 = uncapture(type2);
if (isDoubleType(type1)) return unbox(type1);
if (isDoubleType(type2)) return unbox(type2);
if (isFloatType(type1)) return unbox(type1);
@@ -0,0 +1,11 @@
import java.util.*;
import java.io.*;
class X {
public void save(Collection<? extends Long> value) throws IOException {
assert value.isEmpty() || value.size() == 1;
writeLONG(value.isEmpty() ? 0 : value.iterator().next());
}
public static void writeLONG(long val) throws IOException {
}
}
@@ -25,9 +25,7 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.GenericsUtil;
import com.intellij.psi.PsiManager;
import com.intellij.psi.PsiType;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;
@@ -442,4 +440,5 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testCheckAccessibilityBeforeSuperFieldReferenceInSuperCall() { doTest6(false); }
public void testIDEA128159() { doTest6(false); }
public void testIDEA139214() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_8, false); }
public void testUnboxingWildcards() { doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_8, false); }
}