mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
check context for functional expressions once (IDEA-159362)
This commit is contained in:
-8
@@ -278,14 +278,6 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
PsiType checkType = typeElement.getType();
|
||||
PsiType operandType = operand.getType();
|
||||
if (operandType == null) return null;
|
||||
if (operandType instanceof PsiLambdaExpressionType) {
|
||||
return HighlightInfo
|
||||
.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip("Lambda expression is not expected here").create();
|
||||
}
|
||||
if (operandType instanceof PsiMethodReferenceType) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(
|
||||
"Method reference expression is not expected here").create();
|
||||
}
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(operandType)
|
||||
|| TypeConversionUtil.isPrimitiveAndNotNull(checkType)
|
||||
|| !TypeConversionUtil.areTypesConvertible(operandType, checkType)) {
|
||||
|
||||
+6
@@ -1285,6 +1285,12 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
}
|
||||
myHolder.add(HighlightNamesUtil.highlightClassNameInQualifier(expression, colorsScheme));
|
||||
}
|
||||
|
||||
if (!LambdaUtil.isValidLambdaContext(expression.getParent())) {
|
||||
myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression)
|
||||
.descriptionAndTooltip("Method reference expression is not expected here").create());
|
||||
}
|
||||
|
||||
if (!myHolder.hasErrorResults()) {
|
||||
final PsiType functionalInterfaceType = expression.getFunctionalInterfaceType();
|
||||
if (functionalInterfaceType != null) {
|
||||
|
||||
+12
-2
@@ -1,6 +1,10 @@
|
||||
public class Test {
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
{
|
||||
if (<error descr="Method reference expression is not expected here">Test::length instanceof String</error>) {
|
||||
if (<error descr="Method reference expression is not expected here">Test::length</error> instanceof String) {
|
||||
}
|
||||
bar(Test::length);
|
||||
}
|
||||
@@ -14,4 +18,10 @@ public class Test {
|
||||
interface Bar {
|
||||
Integer _(String s);
|
||||
}
|
||||
|
||||
void f() throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(""))) {
|
||||
for (String line : <error descr="Method reference expression is not expected here">reader::lines</error>) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user