mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
raw diamond substitution: infer Object for jdk < 1.8 (IDEA-133733)
This commit is contained in:
@@ -18,6 +18,8 @@ package com.intellij.psi;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.JavaVersionService;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -167,6 +169,12 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
final DiamondInferenceResult result = new DiamondInferenceResult(classOrAnonymousClassReference.getReferenceName() + "<>");
|
||||
|
||||
if (PsiUtil.isRawSubstitutor(staticFactory, inferredSubstitutor)) {
|
||||
if (!JavaVersionService.getInstance().isAtLeast(argumentList, JavaSdkVersion.JDK_1_8) &&
|
||||
PsiUtil.skipParenthesizedExprUp(newExpression.getParent()) instanceof PsiExpressionList) {
|
||||
for (PsiTypeParameter parameter : parameters) {
|
||||
result.addInferredType(PsiType.getJavaLangObject(psiClass.getManager(), GlobalSearchScope.allScope(psiClass.getProject())));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -3,4 +3,14 @@ import java.util.*;
|
||||
class Sample {
|
||||
public static List getList() {return null;}
|
||||
List<Integer> list = new ArrayList<>(getList());
|
||||
|
||||
void foo() {
|
||||
barz<error descr="'barz(java.util.Map<java.lang.String,java.lang.String[]>)' in 'Sample' cannot be applied to '(java.util.HashMap<java.lang.Object,java.lang.Object>)'">(new HashMap<>(create()))</error>;
|
||||
}
|
||||
|
||||
Map create() {
|
||||
return null;
|
||||
}
|
||||
|
||||
void barz(Map<String, String[]> map) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user