[java] support comparing when method is a first operand

GitOrigin-RevId: 64895b894c8dee5c178bfb336a4f2f30872a13c4
This commit is contained in:
Mikhail Pyltsin
2023-04-13 10:34:44 +02:00
committed by intellij-monorepo-bot
parent f77617b690
commit 4882e88dbf
3 changed files with 25 additions and 0 deletions

View File

@@ -921,6 +921,13 @@ public final class ExpectedTypesProvider {
if (op == JavaTokenType.EQEQ || op == JavaTokenType.NE) {
ContainerUtil.addIfNotNull(myResult, getEqualsType(anotherExpr));
}
if (op == JavaTokenType.LT || op == JavaTokenType.LE ||
op == JavaTokenType.GT || op == JavaTokenType.GE) {
PsiType anotherType = anotherExpr != null ? anotherExpr.getType() : null;
if (anotherType != null) {
myResult.add(createInfoImpl(PsiTypes.doubleType(), anotherType));
}
}
final MyParentVisitor visitor = new MyParentVisitor(expr, true, myClassProvider, myVoidable, myUsedAfter, myMaxCandidates);
myExpr = (PsiExpression)myExpr.getParent();
expr.getParent().accept(visitor);

View File

@@ -0,0 +1,11 @@
// "Create method 'test'" "true-preview"
public class Test {
public void testStart() {
if (test() < 1) {
}
}
private int test() {
return 0;
}
}

View File

@@ -0,0 +1,7 @@
// "Create method 'test'" "true-preview"
public class Test {
public void testStart() {
if (te<caret>st() < 1) {
}
}
}