ignore assignments from lambdas in "Constructor assigns value to field defined in superclass" inspection

This commit is contained in:
Bas Leijdekkers
2014-12-04 13:51:47 +01:00
parent 9cc71f8c0d
commit dcf628efbd
2 changed files with 6 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ public class AssignmentToSuperclassFieldInspection extends BaseInspection {
if (!(expression instanceof PsiReferenceExpression)) {
return;
}
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class);
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class);
if (method == null || !method.isConstructor()) {
return;
}
@@ -21,5 +21,9 @@ class B extends AssignmentToSuperclassField {
<warning descr="Assignment to field 'j' defined in superclass 'AssignmentToSuperclassField'">this.j</warning> = 4;
<warning descr="Assignment to field 'k' defined in superclass 'AssignmentToSuperclassField'">super.k</warning>++;
z = 100;
Runnable r = () -> i = 6;
new Object() {{
i = 4;
}};
}
}