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
The inference for Resource Leak Checker's (RLC) annotations incorrectly infers the EnsuresCalledMethods annotation on outer-class resources that are closed by methods within an inner class.
Here, the field fileWriter is declared and owned by the outer class Foo. However, since it is closed inside the inner class InnerFoo, the inference incorrectly annotates it as:
The reference this.fileWriter is incorrect because fileWriter is not a field of the inner class (InnerFoo), but a field of the outer class (Foo). If the annotation should be allowed at all, it needs to properly reference the field as belonging to the outer class.
Additionally, this situation raises some questions about intended behavior:
Should inference allow inner-class methods to ensure called methods on outer-class fields?
If yes, what should the correct syntax for referencing the outer-class field be? (e.g., Foo.this.fileWriter)
Given that the method performing the close operation belongs to the inner class, what should the inferred method name for InheritableMustCall annotation on the outer class be? In this scenario, it clearly cannot use the inner-class method directly as that method isn't accessible in the outer-class context.
I need some clarifications on the intended semantics and proper annotation references.
The text was updated successfully, but these errors were encountered:
I think that if Checker Framework supports it, inferring @EnsuresCalledMethods on the inner class method using syntax like Foo.this.fileWriter is fine. But I don't see how we can infer an @InheritableMustCall method for the outer class; that would need to be a method on Foo itself I think. @iamsanjaymalakar do you have a real code example showing how the inner class method is correctly used to ensure there is no leak? That might help us understand if/how we can handle this.
The inference for Resource Leak Checker's (RLC) annotations incorrectly infers the
EnsuresCalledMethods
annotation on outer-class resources that are closed by methods within an inner class.For example:
Here, the field
fileWriter
is declared and owned by the outer classFoo
. However, since it is closed inside the inner classInnerFoo
, the inference incorrectly annotates it as:The reference this.fileWriter is incorrect because fileWriter is not a field of the inner class (InnerFoo), but a field of the outer class (Foo). If the annotation should be allowed at all, it needs to properly reference the field as belonging to the outer class.
Additionally, this situation raises some questions about intended behavior:
InheritableMustCall
annotation on the outer class be? In this scenario, it clearly cannot use the inner-class method directly as that method isn't accessible in the outer-class context.I need some clarifications on the intended semantics and proper annotation references.
The text was updated successfully, but these errors were encountered: