mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
IDEA-193097 Redundant cast is reported for cast on functional expression inside synchronized()
This commit is contained in:
@@ -541,7 +541,10 @@ public class RedundantCastUtil {
|
||||
if (opposite == null || conditionalType instanceof PsiPrimitiveType &&
|
||||
!Comparing.equal(conditionalType, opposite.getType())) return;
|
||||
}
|
||||
} else if (parent instanceof PsiSynchronizedStatement && expr != null && expr.getType() instanceof PsiPrimitiveType) {
|
||||
}
|
||||
else if (parent instanceof PsiSynchronizedStatement &&
|
||||
expr != null &&
|
||||
(expr.getType() instanceof PsiPrimitiveType || expr instanceof PsiFunctionalExpression)) {
|
||||
return;
|
||||
} else if (expr instanceof PsiLambdaExpression || expr instanceof PsiMethodReferenceExpression) {
|
||||
if (parent instanceof PsiParenthesizedExpression && parent.getParent() instanceof PsiReferenceExpression) {
|
||||
|
||||
@@ -7,6 +7,12 @@ class Test {
|
||||
return s.length();
|
||||
}
|
||||
|
||||
void test() {
|
||||
synchronized ((Bar)Test::length) {
|
||||
System.out.println("Synchronizing on a method reference is a nice thing to try!");
|
||||
}
|
||||
}
|
||||
|
||||
interface Bar {
|
||||
Integer m(String s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user