mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inferred type check for raw constraints (IDEA-147529)
This commit is contained in:
+8
-1
@@ -71,7 +71,14 @@ public class GenericsHighlightUtil {
|
||||
static HighlightInfo checkInferredTypeArguments(PsiTypeParameter[] typeParameters,
|
||||
PsiElement call,
|
||||
PsiSubstitutor substitutor) {
|
||||
final Pair<PsiTypeParameter, PsiType> inferredTypeArgument = GenericsUtil.findTypeParameterWithBoundError(typeParameters, substitutor, call, false);
|
||||
return checkInferredTypeArguments(typeParameters, call, substitutor, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static HighlightInfo checkInferredTypeArguments(PsiTypeParameter[] typeParameters,
|
||||
PsiElement call,
|
||||
PsiSubstitutor substitutor, boolean allowUncheckedConversion) {
|
||||
final Pair<PsiTypeParameter, PsiType> inferredTypeArgument = GenericsUtil.findTypeParameterWithBoundError(typeParameters, substitutor, call, allowUncheckedConversion);
|
||||
if (inferredTypeArgument != null) {
|
||||
final PsiType extendsType = inferredTypeArgument.second;
|
||||
final PsiTypeParameter typeParameter = inferredTypeArgument.first;
|
||||
|
||||
+1
-1
@@ -1341,7 +1341,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
assert containingClass != null : method;
|
||||
typeParameters = ArrayUtil.mergeArrays(typeParameters, containingClass.getTypeParameters());
|
||||
}
|
||||
myHolder.add(GenericsHighlightUtil.checkInferredTypeArguments(typeParameters, expression, result.getSubstitutor()));
|
||||
myHolder.add(GenericsHighlightUtil.checkInferredTypeArguments(typeParameters, expression, result.getSubstitutor(), true));
|
||||
}
|
||||
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import java.io.Serializable;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
class Test {
|
||||
|
||||
interface HasCode<T extends Serializable> {
|
||||
static <U extends Serializable, T extends Enum<T> & HasCode<U>> T fromCode(U code, Class<T> classEnum) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
enum EnumRaw implements HasCode {
|
||||
;
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
final BiConsumer<String, Class<EnumRaw>> code = HasCode::fromCode;
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -450,6 +450,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testRawInferredTypeCheck() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user