mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-168009 Wrong behavior with capture generics.
This commit is contained in:
+15
-4
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.signatures;
|
||||
|
||||
import com.intellij.psi.PsiParameter;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
|
||||
/**
|
||||
* Created by Max Medvedev on 14/03/14
|
||||
@@ -47,7 +46,19 @@ class GrClosureParameterImpl implements GrClosureParameter {
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiType getType() {
|
||||
PsiType type = mySubstitutor.substitute(myParameter.getType());
|
||||
PsiType typeParameter = myParameter.getType();
|
||||
PsiType type = mySubstitutor.substitute(typeParameter);
|
||||
if (typeParameter instanceof PsiClassType) {
|
||||
final PsiClass parameterClass = ((PsiClassType)typeParameter).resolve();
|
||||
if (parameterClass instanceof PsiTypeParameter && type != null) {
|
||||
|
||||
PsiClassType[] types = parameterClass.getExtendsListTypes();
|
||||
if (types.length > 0 && !TypesUtil.isAssignableByMethodCallConversion(types[0], type, myParameter)) {
|
||||
type = types[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return myEraseType ? TypeConversionUtil.erasure(type) : type;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -225,9 +225,11 @@ public class SubstitutorComputer {
|
||||
return argType;
|
||||
}
|
||||
|
||||
if (!TypesUtil.isAssignable(TypeConversionUtil.erasure(paramType), argType, myPlace) &&
|
||||
TypesUtil.isAssignableByMethodCallConversion(paramType, argType, myPlace)) {
|
||||
return paramType;
|
||||
if (!TypesUtil.isAssignable( TypeConversionUtil.erasure(paramType), argType, myPlace)) {
|
||||
if (TypesUtil.isAssignableByMethodCallConversion(paramType, argType, myPlace)) {
|
||||
return paramType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return argType;
|
||||
}
|
||||
|
||||
+29
@@ -278,4 +278,33 @@ class GrGenericsInferringTest extends GrHighlightingTestBase {
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
void testBoundedGenericsCompileStatic() {
|
||||
testHighlighting '''
|
||||
import groovy.transform.CompileStatic
|
||||
|
||||
@CompileStatic
|
||||
class Foo {
|
||||
static <T extends List<Integer>> void bar(T a) {
|
||||
}
|
||||
|
||||
static void method() {
|
||||
bar<error>([''])</error>
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
void testBoundedGenerics() {
|
||||
testHighlighting '''
|
||||
class Foo {
|
||||
static <T extends List<Integer>> void bar(T a) {
|
||||
}
|
||||
|
||||
static void method() {
|
||||
bar([''])
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user