mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
new inference: 18.5.2 adjustments
This commit is contained in:
@@ -288,13 +288,9 @@ public class InferenceIncorporationPhase {
|
||||
*/
|
||||
private void upDown(List<PsiType> eqBounds, List<PsiType> upperBounds) {
|
||||
for (PsiType upperBound : upperBounds) {
|
||||
if (mySession.isProperType(upperBound)) {
|
||||
continue;
|
||||
}
|
||||
if (upperBound == null) continue;
|
||||
for (PsiType eqBound : eqBounds) {
|
||||
if (mySession.isProperType(eqBound)) {
|
||||
continue;
|
||||
}
|
||||
if (eqBound == null) continue;
|
||||
addConstraint(new StrictSubtypingConstraint(upperBound, eqBound));
|
||||
}
|
||||
}
|
||||
@@ -306,14 +302,8 @@ public class InferenceIncorporationPhase {
|
||||
private void eqEq(List<PsiType> eqBounds) {
|
||||
for (int i = 0; i < eqBounds.size(); i++) {
|
||||
PsiType sBound= eqBounds.get(i);
|
||||
if (mySession.isProperType(sBound)) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i + 1; j < eqBounds.size(); j++) {
|
||||
final PsiType tBound = eqBounds.get(j);
|
||||
if (mySession.isProperType(tBound)) {
|
||||
continue;
|
||||
}
|
||||
addConstraint(new TypeEqualityConstraint(tBound, sBound));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,46 +192,68 @@ public class InferenceSession {
|
||||
@Nullable PsiCallExpression parent,
|
||||
PsiMethod parentMethod) {
|
||||
if (!repeatInferencePhases(true)) {
|
||||
return null;
|
||||
//inferred result would be checked as candidate won't be applicable
|
||||
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
initReturnTypeConstraint(parentMethod, parent);
|
||||
if (!repeatInferencePhases(true)) {
|
||||
return null;
|
||||
return prepareSubstitution();
|
||||
}
|
||||
|
||||
if (parameters != null && args != null) {
|
||||
final Set<ConstraintFormula> additionalConstraints = new HashSet<ConstraintFormula>();
|
||||
if (parameters.length > 0) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] != null) {
|
||||
PsiType parameterType = getParameterType(parameters, args, i, mySiteSubstitutor);
|
||||
if (!isPertinentToApplicability(args[i], parentMethod)) {
|
||||
additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
|
||||
}
|
||||
additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(args[i], parameterType));
|
||||
}
|
||||
}
|
||||
collectAdditionalConstraints(parameters, args, parentMethod, additionalConstraints);
|
||||
}
|
||||
|
||||
if (!additionalConstraints.isEmpty() && !proceedWithAdditionalConstraints(additionalConstraints)) {
|
||||
return null;
|
||||
return prepareSubstitution();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PsiSubstitutor.EMPTY;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void collectAdditionalConstraints(PsiParameter[] parameters,
|
||||
PsiExpression[] args,
|
||||
PsiMethod parentMethod,
|
||||
Set<ConstraintFormula> additionalConstraints) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] != null) {
|
||||
PsiType parameterType = getParameterType(parameters, args, i, mySiteSubstitutor);
|
||||
if (!isPertinentToApplicability(args[i], parentMethod)) {
|
||||
additionalConstraints.add(new ExpressionCompatibilityConstraint(args[i], parameterType));
|
||||
}
|
||||
additionalConstraints.add(new CheckedExceptionCompatibilityConstraint(args[i], parameterType));
|
||||
if (args[i] instanceof PsiCallExpression) {
|
||||
//If the expression is a poly class instance creation expression (15.9) or a poly method invocation expression (15.12),
|
||||
//the set contains all constraint formulas that would appear in the set C when determining the poly expression's invocation type.
|
||||
final PsiCallExpression callExpression = (PsiCallExpression)args[i];
|
||||
final PsiExpressionList argumentList = callExpression.getArgumentList();
|
||||
if (argumentList != null) {
|
||||
final PsiMethod method = callExpression.resolveMethod();
|
||||
if (method != null) {
|
||||
final PsiExpression[] newArgs = argumentList.getExpressions();
|
||||
final PsiParameter[] newParams = method.getParameterList().getParameters();
|
||||
collectAdditionalConstraints(newParams, newArgs, method, additionalConstraints);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiSubstitutor infer(@Nullable PsiParameter[] parameters,
|
||||
@Nullable PsiExpression[] args,
|
||||
@Nullable PsiElement parent) {
|
||||
final Pair<PsiMethod, PsiCallExpression> pair = getPair(parent);
|
||||
final PsiSubstitutor subst = tryToInfer(parameters, args, pair != null ? pair.second : null, pair != null ? pair.first : null);
|
||||
if (subst == null) {
|
||||
return resolveSubset(myInferenceVariables.values(), mySiteSubstitutor, false);
|
||||
if (subst != null) {
|
||||
return subst;
|
||||
}
|
||||
|
||||
final PsiSubstitutor substitutor = resolveBounds(myInferenceVariables.values(), mySiteSubstitutor);
|
||||
@@ -529,7 +551,7 @@ public class InferenceSession {
|
||||
final PsiTypeParameter[] typeParameters = ((PsiMethod)parentMethod).getTypeParameters();
|
||||
final InferenceSession session = new InferenceSession(typeParameters, ((MethodCandidateInfo)result).getSiteSubstitutor(), myManager, argumentList);
|
||||
session.initExpressionConstraints(parameters, args, argumentList, (PsiMethod)parentMethod);
|
||||
if (session.tryToInfer(parameters, args, callExpression, (PsiMethod)parentMethod) == null) {
|
||||
if (session.tryToInfer(parameters, args, callExpression, (PsiMethod)parentMethod) != null) {
|
||||
return null;
|
||||
}
|
||||
final Collection<PsiTypeParameter> params = session.getTypeParams();
|
||||
@@ -751,7 +773,9 @@ public class InferenceSession {
|
||||
lowerBound = substituteNonProperBound(lowerBound, substitutor);
|
||||
final HashSet<InferenceVariable> dependencies = new HashSet<InferenceVariable>();
|
||||
collectDependencies(lowerBound, dependencies);
|
||||
if (dependencies.isEmpty() || isInsideRecursiveCall(dependencies)) {
|
||||
if (dependencies.size() == 1 && dependencies.contains(variable) && isInsideRecursiveCall(dependencies)) {
|
||||
lub = JavaPsiFacade.getElementFactory(myManager.getProject()).createType(variable.getParameter());
|
||||
} else if (dependencies.isEmpty() || isInsideRecursiveCall(dependencies)) {
|
||||
if (lub == PsiType.NULL) {
|
||||
lub = lowerBound;
|
||||
}
|
||||
@@ -794,10 +818,21 @@ public class InferenceSession {
|
||||
|
||||
private boolean proceedWithAdditionalConstraints(Set<ConstraintFormula> additionalConstraints) {
|
||||
while (!additionalConstraints.isEmpty()) {
|
||||
//extract subset of constraints
|
||||
final Set<ConstraintFormula> subset = buildSubset(additionalConstraints);
|
||||
|
||||
//collect all input variables of selection
|
||||
final Set<InferenceVariable> varsToResolve = new HashSet<InferenceVariable>();
|
||||
for (ConstraintFormula formula : subset) {
|
||||
if (formula instanceof InputOutputConstraintFormula) {
|
||||
final Set<InferenceVariable> inputVariables = ((InputOutputConstraintFormula)formula).getInputVariables(this);
|
||||
if (inputVariables != null) {
|
||||
varsToResolve.addAll(inputVariables);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Set<ConstraintFormula> subset = buildSubset(additionalConstraints, varsToResolve);
|
||||
|
||||
//resolve input variables
|
||||
PsiSubstitutor substitutor = resolveSubset(varsToResolve, mySiteSubstitutor, true);
|
||||
|
||||
if (substitutor == null) {
|
||||
@@ -823,8 +858,7 @@ public class InferenceSession {
|
||||
return true;
|
||||
}
|
||||
|
||||
private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints,
|
||||
final Set<InferenceVariable> varsToResolve) {
|
||||
private Set<ConstraintFormula> buildSubset(final Set<ConstraintFormula> additionalConstraints) {
|
||||
|
||||
final Set<ConstraintFormula> subset = new HashSet<ConstraintFormula>();
|
||||
final Set<InferenceVariable> outputVariables = new HashSet<InferenceVariable>();
|
||||
@@ -854,10 +888,6 @@ public class InferenceSession {
|
||||
}
|
||||
if (!dependsOnOutput) {
|
||||
subset.add(constraint);
|
||||
for (InferenceVariable variable : inputVariables) {
|
||||
varsToResolve.addAll(variable.getDependencies(this));
|
||||
varsToResolve.add(variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -152,8 +152,7 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
session.initBounds(method.getTypeParameters());
|
||||
session.initBounds(containingClass.getTypeParameters());
|
||||
|
||||
if (typeParameters.length == 0 && ((PsiMethod)resolve).getTypeParameters().length > 0) {
|
||||
|
||||
if (typeParameters.length == 0 && method.getTypeParameters().length > 0) {
|
||||
final PsiClass interfaceClass = classResolveResult.getElement();
|
||||
LOG.assertTrue(interfaceClass != null);
|
||||
if (PsiPolyExpressionUtil.mentionsTypeParameters(referencedMethodReturnType,
|
||||
@@ -176,7 +175,8 @@ public class PsiMethodReferenceCompatibilityConstraint implements ConstraintForm
|
||||
}
|
||||
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
if (targetParameters.length == parameters.length + 1 && !method.isVarArgs()) {
|
||||
if (targetParameters.length == parameters.length + 1 && !method.isVarArgs() &&
|
||||
PsiPolyExpressionUtil.mentionsTypeParameters(referencedMethodReturnType, ContainerUtil.newHashSet(containingClass.getTypeParameters()))) { //todo specification bug?
|
||||
specialCase(session, constraints, substitutor, targetParameters);
|
||||
}
|
||||
constraints.add(new TypeCompatibilityConstraint(returnType, psiSubstitutor.substitute(referencedMethodReturnType)));
|
||||
|
||||
@@ -50,8 +50,8 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
return TypeConversionUtil.isAssignable(myT, myS);
|
||||
}
|
||||
|
||||
if (PsiType.NULL.equals(myS) || myS == null) return true;
|
||||
if (PsiType.NULL.equals(myT) || myT == null) return false;
|
||||
if (PsiType.NULL.equals(myS) || myS == null || myT.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) return true;
|
||||
|
||||
InferenceVariable inferenceVariable = session.getInferenceVariable(myS);
|
||||
if (inferenceVariable != null) {
|
||||
|
||||
@@ -488,9 +488,6 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
session.addConstraint(new TypeCompatibilityConstraint(getParameterType(parameters, i, varargs), interfaceParamType));
|
||||
}
|
||||
}
|
||||
else {
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
if (!session.repeatInferencePhases(false)) {
|
||||
if (method.isVarArgs() && !varargs) {
|
||||
|
||||
@@ -7,6 +7,6 @@ abstract class Test {
|
||||
abstract <T> T test(Serializable type);
|
||||
|
||||
private void call(){
|
||||
<error descr="Incompatible types. Found: 'java.lang.String[]', required: 'java.lang.String'">String s = test(String[].class);</error>
|
||||
String s = test<error descr="'test(java.lang.Class<T>)' in 'Test' cannot be applied to '(java.lang.Class<java.lang.String[]>)'">(String[].class)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ class A<T> {
|
||||
}
|
||||
|
||||
void bar(A<?> x){
|
||||
baz<error descr="'baz(A<A<? extends S>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
|
||||
baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
|
||||
}
|
||||
|
||||
<S> void baz(A<A<? extends S>> x){}
|
||||
|
||||
@@ -9,8 +9,8 @@ class B<L> {
|
||||
void bar(B<?> b, A<?, ?> foo1) {
|
||||
baz(b.foo());
|
||||
A<?, ?> foo = b.foo();
|
||||
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
|
||||
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
|
||||
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
|
||||
baz<error descr="'baz(A<capture<?>,capture<?>>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
|
||||
}
|
||||
|
||||
<K> void baz(A<K, K> a) {
|
||||
|
||||
@@ -2,6 +2,6 @@ class A<T> {
|
||||
<T extends A<T>> void foo(T x){}
|
||||
|
||||
void bar(A<?> x){
|
||||
foo<error descr="'foo(T)' in 'A' cannot be applied to '(A<capture<?>>)'">(x)</error>;
|
||||
<error descr="Inferred type 'A<capture<?>>' for type parameter 'T' is not within its bound; should extend 'A<A<capture<?>>>'">foo(x)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ class B<T> extends A<A<T>> {
|
||||
foo2(sb);
|
||||
foo2(s);
|
||||
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo3<error descr="'foo3(A<A<? extends T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
|
||||
foo4<error descr="'foo4(A<A<? super java.lang.Object>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
|
||||
|
||||
foo5(b);
|
||||
foo5(eb);
|
||||
|
||||
@@ -11,6 +11,6 @@ abstract class A1{
|
||||
abstract <T> T baz(List<? super T> a);
|
||||
|
||||
void bar(List<?> x){
|
||||
String o = baz<error descr="'baz(java.util.List<? super T>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
|
||||
String o = baz<error descr="'baz(java.util.List<? super java.lang.Object>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ abstract class A {
|
||||
abstract <T> T baz(List<? super List<? super T>> a);
|
||||
|
||||
void bar(C<?> x){
|
||||
baz<error descr="'baz(java.util.List<? super java.util.List<? super T>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
|
||||
baz<error descr="'baz(java.util.List<? super java.util.List<? super java.lang.Object>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class C<T extends C<? extends C<? extends T>>>{
|
||||
void foo(C<?> x){
|
||||
bar<error descr="'bar(C<T>)' in 'C' cannot be applied to '(C<capture<?>>)'">(x)</error>;
|
||||
<error descr="Inferred type 'capture<? extends C<? extends C<capture<?>>>>' for type parameter 'T' is not within its bound; should extend 'C<capture<? extends C<? extends C<capture<?>>>>>'">bar(x)</error>;
|
||||
}
|
||||
<T extends C<? extends T>> void bar(C<T> x){}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ abstract class B {
|
||||
|
||||
void bar(List<List<?>> x, List<List<List<?>>> y){
|
||||
foo(x) [0] = "";
|
||||
foo1<error descr="'foo1(java.util.List<? extends java.util.List<T>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
|
||||
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<T>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
|
||||
foo1<error descr="'foo1(java.util.List<? extends java.util.List<java.lang.Object>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<?>>)'">(x)</error> [0] = "";
|
||||
foo2<error descr="'foo2(java.util.List<java.util.List<? super java.util.List<java.lang.Object>>>)' in 'B' cannot be applied to '(java.util.List<java.util.List<java.util.List<?>>>)'">(y)</error> [0] = "";
|
||||
|
||||
String s = foo0(x);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Test {
|
||||
|
||||
public void test(Set<MyConsumer> set) {
|
||||
@SuppressWarnings("unchecked")
|
||||
<error descr="Incompatible types. Found: 'java.util.Map<java.lang.Object,Test.MyConsumer>', required: 'java.util.Map<Test.Parent,Test.MyConsumer<Test.Parent>>'">Map<Parent, MyConsumer<Parent>> map = create(set);</error>
|
||||
Map<Parent, MyConsumer<Parent>> map = create<error descr="'create(java.util.Set<T>)' in 'Test' cannot be applied to '(java.util.Set<Test.MyConsumer>)'">(set)</error>;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ class GenericsTest98 {
|
||||
List<Movable<? extends Serializable>> list = new ArrayList<Movable<? extends Serializable>> ();
|
||||
Factory factory = Factory.newInstance();
|
||||
// Doesn't compile, but Idea doesn't complain
|
||||
Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<T>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
|
||||
Mover<? extends Serializable> mover = factory.getNew<error descr="'getNew(java.util.List<? extends Movable<java.io.Serializable>>)' in 'Factory' cannot be applied to '(java.util.List<Movable<? extends java.io.Serializable>>)'">(list)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class D<T> {
|
||||
void foo(D<?> x){
|
||||
bar<error descr="'bar(D<? extends T>, D<? super T>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
|
||||
bar<error descr="'bar(D<?>, D<? super java.lang.Object>)' in 'D' cannot be applied to '(D<capture<?>>, D<capture<?>>)'">(x,x)</error>;
|
||||
}
|
||||
<T> void bar(D<? extends T> x, D<? super T> y){}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class CaptureTest {
|
||||
}
|
||||
|
||||
void foo (Class<? extends Emum<CaptureTest>> clazz) {
|
||||
Emum.valueOf<error descr="'valueOf(java.lang.Class<T>, java.lang.String)' in 'CaptureTest.Emum' cannot be applied to '(java.lang.Class<capture<? extends CaptureTest.Emum<CaptureTest>>>, java.lang.String)'">(clazz, "CCC")</error>;
|
||||
<error descr="Inferred type 'capture<? extends CaptureTest.Emum<CaptureTest>>' for type parameter 'T' is not within its bound; should extend 'CaptureTest.Emum<capture<? extends CaptureTest.Emum<CaptureTest>>>'">Emum.valueOf(clazz, "CCC")</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class S2 {
|
||||
}
|
||||
|
||||
void bar(List<? extends S2> k) {
|
||||
f<error descr="'f(java.util.List<T>, java.util.List<T>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
|
||||
f<error descr="'f(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)' in 'S2' cannot be applied to '(java.util.List<capture<? extends S2>>, java.util.List<capture<? extends S2>>)'">(k, k)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ class S3 {
|
||||
}
|
||||
|
||||
void bar(Map<? extends S3, ? extends S3> k) {
|
||||
f<error descr="'f(java.util.Map<T,T>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
|
||||
f<error descr="'f(java.util.Map<capture<? extends S3>,capture<? extends S3>>)' in 'S3' cannot be applied to '(java.util.Map<capture<? extends S3>,capture<? extends S3>>)'">(k)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class TypeBug {
|
||||
|
||||
multiList.add(intHolder);
|
||||
multiList.add(doubleHolder);
|
||||
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<T>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
|
||||
swapFirstTwoValues<error descr="'swapFirstTwoValues(java.util.List<TypeBug.ValueHolder<java.lang.Object>>)' in 'TypeBug' cannot be applied to '(java.util.List<TypeBug.ValueHolder<?>>)'">(multiList)</error>; //need to be highlighted
|
||||
|
||||
// this line causes a ClassCastException when checked.
|
||||
Integer value = intHolder.value;
|
||||
|
||||
@@ -10,6 +10,6 @@ class Node<NodeTypeT extends NodeType> {
|
||||
|
||||
class Main {
|
||||
public static void main(NodeProperty<NumberExpression, Integer> nval, Node<? extends NodeType> expr) {
|
||||
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,ValueT>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
|
||||
int val = expr.get<error descr="'get(NodeProperty<? super capture<? extends NodeType>,java.lang.Object>)' in 'Node' cannot be applied to '(NodeProperty<NumberExpression,java.lang.Integer>)'">(nval)</error>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ConcurrentCollectors {
|
||||
static <T, K, D, M1 extends Map<K, D>> C<T, M1> groupingBy(F<M1> f,
|
||||
C<T, D> c,
|
||||
BiConsumer<M1, T> consumer) {
|
||||
return new CImpl<><error descr="'CImpl(ConcurrentCollectors.F<R>, ConcurrentCollectors.BiConsumer<R,T>, ConcurrentCollectors.BiOp<R>)' in 'ConcurrentCollectors.CImpl' cannot be applied to '(ConcurrentCollectors.F<M1>, ConcurrentCollectors.BiConsumer<M1,T>, ConcurrentCollectors.BiOp<ConcurrentCollectors.ConcurrentMap<java.lang.Object,D>>)'">(f, consumer, arg(c.getOp()))</error>;
|
||||
return new CImpl<>(f, consumer, arg<error descr="'arg(ConcurrentCollectors.BiOp<V>)' in 'ConcurrentCollectors.Test3' cannot be applied to '(ConcurrentCollectors.BiOp<D>)'">(c.getOp())</error>);
|
||||
}
|
||||
|
||||
static <K, V, M2 extends ConcurrentMap<K, V>> BiOp<M2> arg(BiOp<V> op) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class NoInferenceResult {
|
||||
m((String s1) -> s1.length());
|
||||
m((String s1) -> s1);
|
||||
|
||||
m1(<error descr="Target type of a lambda conversion must be an interface">() -> { }</error>);
|
||||
m1<error descr="'m1(T)' in 'NoInferenceResult' cannot be applied to '(<lambda expression>)'">(() -> { })</error>;
|
||||
|
||||
Foo<String> foo = new Foo<String>();
|
||||
foo.map(v -> null);
|
||||
|
||||
@@ -25,7 +25,7 @@ class ReturnTypeIncompatibility {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I2<Integer>)' match">(i-> {return i;})</error>;
|
||||
call<error descr="Ambiguous method call: both 'ReturnTypeIncompatibility.call(I1<Integer>)' and 'ReturnTypeIncompatibility.call(I2<P>)' match">(i-> {return i;})</error>;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Test1 {
|
||||
if (s.equals("1")) {
|
||||
return Option.option(1);
|
||||
} else {
|
||||
return Option.option<error descr="'option(java.lang.Integer)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
|
||||
return Option.option<error descr="'option(T)' in 'Test1.Option' cannot be applied to '(java.lang.String)'">("2")</error>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class TypeArgsConsistency {
|
||||
I<Integer> i1 = (i, j) -> i + j;
|
||||
foo((i, j) -> i + j);
|
||||
I<Integer> i2 = bar((i, j) -> i + j);
|
||||
I<Integer> i3 = bar(<error descr="Incompatible return type String in lambda expression">(i, j) -> "" + i + j</error>);
|
||||
I<Integer> i3 = bar(<error descr="Cyclic inference">(i, j) -> "" + i + j</error>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class TypeArgsConsistency2 {
|
||||
I<Integer> i1 = bar(x -> x);
|
||||
I1<Integer> i2 = bar1(x -> 1);
|
||||
I2<String> aI2 = bar2(x -> "");
|
||||
I2<Integer> aI28 = bar2( <error descr="Incompatible return type String in lambda expression">x-> ""</error>);
|
||||
I2<Integer> aI28 = bar2( <error descr="Cyclic inference">x-> ""</error>);
|
||||
I2<Integer> i3 = bar2(x -> x);
|
||||
I2<Integer> i4 = bar2(x -> foooI());
|
||||
System.out.println(i4.foo(2));
|
||||
|
||||
@@ -14,7 +14,7 @@ class NoLambda {
|
||||
static <T> T id(T i2) {return i2;}
|
||||
|
||||
{
|
||||
id(<error descr="Target type of a lambda conversion must be an interface">() -> {System.out.println("hi");}</error>);
|
||||
id<error descr="'id(T)' in 'NoLambda' cannot be applied to '(<lambda expression>)'">(() -> {System.out.println("hi");})</error>;
|
||||
NoLambda.<Runnable>id(() -> {System.out.println("hi");});
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ class Foo<R> {
|
||||
|
||||
public void foo() {
|
||||
reduce(Moo::new);
|
||||
reduce(<error descr="Cyclic inference">AMoo::new</error>);
|
||||
<error descr="Inferred type 'Foo<R>.AMoo' for type parameter 'S' is not within its bound; should implement 'Foo.ASink<java.lang.Object,Foo<R>.AMoo>'">reduce(AMoo::new)</error>;
|
||||
reduce(AAMoo::new);
|
||||
reduce(AAAMoo::new);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Test1111 {
|
||||
}
|
||||
|
||||
public void test(I<?> i) {
|
||||
bar<error descr="'bar(Test1111.I<? super A>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
|
||||
bar<error descr="'bar(Test1111.I<? super java.lang.Object>)' in 'Test1111' cannot be applied to '(Test1111.I<capture<?>>)'">(i)</error>;
|
||||
}
|
||||
|
||||
public static <A> void bar(I<? super A> i) {}
|
||||
|
||||
@@ -9,7 +9,7 @@ class Test {
|
||||
|
||||
<R> SuperFoo<R> foo(I<R> ax) { return null; }
|
||||
|
||||
SuperFoo<String> ls = foo(() -> new Foo<<error descr="Type parameter 'java.lang.String' is not within its bound; should extend 'java.lang.Number'"></error>>());
|
||||
SuperFoo<String> ls = foo(<error descr="Incompatible return type Foo<X> in lambda expression">() -> new Foo<>()</error>);
|
||||
SuperFoo<Integer> li = foo(() -> new Foo<>());
|
||||
SuperFoo<?> lw = foo(() -> new Foo<>());
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public class Bug
|
||||
{
|
||||
final I<CRN> f = null;
|
||||
|
||||
Bug.<String>create<error descr="'create(Bug.I<java.lang.String>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(fn(f))</error>;
|
||||
Bug.<String>create(fn<error descr="'fn(Bug.I<FN>)' in 'Bug' cannot be applied to '(Bug.I<CRN>)'">(f)</error>);
|
||||
|
||||
return create(fn(f));
|
||||
|
||||
|
||||
@@ -15,4 +15,21 @@ class Test {
|
||||
}
|
||||
|
||||
public static <C> void foo(Function<String, C> fn) { }
|
||||
}
|
||||
}
|
||||
|
||||
class Test1 {
|
||||
|
||||
interface Function<K> {
|
||||
K _();
|
||||
}
|
||||
|
||||
static {
|
||||
foo(Test1::asList);
|
||||
}
|
||||
|
||||
public static <T> List<T> asList(T... a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <C> void foo(Function<C> fn) { }
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testInferenceWithUpperBoundPromotion() {
|
||||
doTest();
|
||||
}
|
||||
public void _testVariance() { //todo waiting for capture bound
|
||||
public void testVariance() {
|
||||
doTest();
|
||||
}
|
||||
public void testForeachTypes() {
|
||||
@@ -244,7 +244,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA66311_16() {
|
||||
doTest();
|
||||
}
|
||||
public void _testIDEA76283() {//todo bounds
|
||||
public void testIDEA76283() {
|
||||
doTest();
|
||||
}
|
||||
public void testIDEA74899() {
|
||||
@@ -262,7 +262,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA57339() {
|
||||
doTest();
|
||||
}
|
||||
public void _testIDEA57340() {
|
||||
public void testIDEA57340() {
|
||||
doTest();
|
||||
}
|
||||
public void testIDEA89771() {
|
||||
@@ -295,7 +295,7 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA57563() {
|
||||
doTest();
|
||||
}
|
||||
public void _testIDEA57275() {
|
||||
public void testIDEA57275() {
|
||||
doTest();
|
||||
}
|
||||
public void testIDEA57533() {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void _testCapturedReturnTypes() throws Exception {
|
||||
public void testCapturedReturnTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testErasedByReturnConstraint() throws Exception {
|
||||
public void _testErasedByReturnConstraint() throws Exception { //todo waiting for erasure constraints
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void _testAdditionalConstraintSubstitution() throws Exception {
|
||||
public void testAdditionalConstraintSubstitution() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void _testIncludeContainingClassParamsInResolveSetForConstructorRefs() throws Exception {
|
||||
public void testIncludeContainingClassParamsInResolveSetForConstructorRefs() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user