mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate wildcard type to ensure valid assignment (IDEA-148644)
This commit is contained in:
+4
-2
@@ -87,7 +87,9 @@ public final class FieldFromParameterUtils {
|
||||
|
||||
PsiSubstitutor subst = PsiSubstitutor.EMPTY;
|
||||
for (PsiTypeParameter usedTypeParameter : usedTypeParameters) {
|
||||
subst = subst.put(usedTypeParameter, TypeConversionUtil.typeParameterErasure(usedTypeParameter));
|
||||
final PsiType bound = TypeConversionUtil.typeParameterErasure(usedTypeParameter);
|
||||
final PsiManager manager = usedTypeParameter.getManager();
|
||||
subst = subst.put(usedTypeParameter, bound == null ? PsiWildcardType.createUnbounded(manager) : bound.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? bound : PsiWildcardType.createExtends(manager, bound));
|
||||
}
|
||||
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
@@ -98,7 +100,7 @@ public final class FieldFromParameterUtils {
|
||||
}
|
||||
|
||||
if (psiClass instanceof PsiTypeParameter) {
|
||||
return subst.substitute((PsiTypeParameter)psiClass);
|
||||
return GenericsUtil.getVariableTypeByExpressionType(subst.substitute((PsiTypeParameter)psiClass));
|
||||
}
|
||||
else {
|
||||
return JavaPsiFacade.getElementFactory(parameter.getProject()).createType(psiClass, substitutor);
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
import java.util.*;
|
||||
class Test{
|
||||
private List<String> myP1;
|
||||
private List<? extends String> myP1;
|
||||
|
||||
<T extends String> void f(List<T> p1){
|
||||
myP1 = p1;
|
||||
|
||||
Reference in New Issue
Block a user