Class CloseableArgumentKeeping
A constructor that stores its own parameter in a closeable property (held: res) takes ownership of the
argument: the holder's operator close will close it. That is a transfer, and it is right only when the
caller hands over a NEW value - Holder(Res("x")). Handing it a value that already has an owner - a try
resource, a parameter, another object's property - gives that one resource two owners, and both close it
(try -> res <- Res() / holder <- Holder(res) closed res twice).
Collected while every source is walked (Walk 1, in parallel), decided once all have been (check()): a
constructor in one file is called in another, and a constructor that passes its own parameter on to
super(...), this(...) or another keeping constructor keeps it too, which is a fixpoint over all of
them. A member of a parameterised type is judged by the generic's own constructor
(GenericTemplateMember).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidcheck()After every source has been walked: close the kept set over the forwards, then report every construction that hands a kept parameter a value that is not new.(package private) voidforwards(MethodSymbol constructor, int fromIndex, MethodSymbol target, int toIndex) The constructor passes its own parameter atfromIndextotargetattoIndex: if the target keeps it, so does this constructor.(package private) voidkeeps(MethodSymbol constructor, int index) The constructor stores its parameter atindexin a closeable property of the object it constructs.(package private) voidnotFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument) A construction is given a closeable value that is not new atindex: an error when the constructor keeps that parameter.
-
Constructor Details
-
CloseableArgumentKeeping
CloseableArgumentKeeping()
-
-
Method Details
-
keeps
The constructor stores its parameter atindexin a closeable property of the object it constructs. -
forwards
The constructor passes its own parameter atfromIndextotargetattoIndex: if the target keeps it, so does this constructor. -
notFresh
void notFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument) A construction is given a closeable value that is not new atindex: an error when the constructor keeps that parameter. -
check
void check()After every source has been walked: close the kept set over the forwards, then report every construction that hands a kept parameter a value that is not new.
-