Java: don't report non-private field as assigned not accessed when it is implicitly read and written (IDEA-357404)

GitOrigin-RevId: 943ef6961c19510e5d4291367293424a87499487
This commit is contained in:
Bas Leijdekkers
2024-09-13 12:37:17 +02:00
committed by intellij-monorepo-bot
parent 624ffd24a6
commit 5c06f74975
5 changed files with 41 additions and 32 deletions

View File

@@ -0,0 +1,15 @@
class <warning descr="Class 'Test' is never used">Test</warning>{
private int <warning descr="Private field 'fieldWritten' is assigned but never accessed">fieldWritten</warning>;
private int fieldWritten2;
int fieldReadWritten;
int <warning descr="Package-private field 'fieldWritten3' is assigned but never accessed">fieldWritten3</warning><EOLError descr="';' expected"></EOLError>
@Override
public int hashCode() {
return fieldWritten2;
}
}

View File

@@ -1,29 +0,0 @@
package javax.annotation;
/*
* Copyright 2000-2011 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@interface Resource {}
class Test{
@Resource
private int <warning descr="Private field 'field' is assigned but never accessed">field</warning>;
@Resource
private int field2;
int f() {
return field2;
}
}