You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
Instance fields requires warnings should be suppressed if the constructor is annotated #2970
[Requires]publicclassSomeDangerousClass{}publicclassAnotherClass{// Warning is being produced hereprivateSomeDangerousClass_instanceField=newSomeDangerousClass();[Requires]publicAnotherClass(){}}
The instance field will generate a warning since SomeDangerousClass is annotated with Requires. Currently, the workaround is to move the initialization explicitly to the constructor
[Requires]publicclassSomeDangerousClass{}publicclassAnotherClass{// Warning is being produced hereprivateSomeDangerousClass_instanceField;[Requires]publicAnotherClass(){_instanceField=newSomeDangerousClass()}}
Then the whole suppression system will look for the parent and suppress the warning. The proposal is that the suppression system should be modified in instance fields to take into account the constructor of the class and their annotation.
Activity